Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

This is my queue selection sort in Ada.

Name: Anonymous 2009-01-20 22:08

   procedure QSort (KQueue: in out Queue_Type) is
      Smallest : Element;
      Candidate : Element;
      TempQueue : Queue_Type;
      EmptyQueue : Queue_Type;
      SortedQueue : Queue_Type;
   begin
      Dequeue(Smallest, KQueue);

      -- Create an empty queue.  A bit hacky
      Enqueue(Smallest, EmptyQueue);Dequeue(Candidate, EmptyQueue);

      loop

         -- We're done
         if KQueue.Queue_State = Empty and TempQueue.Queue_State = Empty then
            Enqueue(Smallest, SortedQueue);
            KQueue := SortedQueue;
            exit;
         end if;

         -- Check the current smallest element against the next item in the input queue
         if KQueue.Queue_State = Filled then
            Dequeue(Candidate, KQueue);
         end if;
         if Smallest < Candidate then
            Enqueue(Candidate, TempQueue);
         else
            Enqueue(Smallest, TempQueue);
            Smallest := Candidate;
         end if;

         -- We found the smallest element in the input queue for this iteration
         if KQueue.Queue_State = Empty then
            if SortedQueue.Top = SortedQueue.Free and SortedQueue.Queue_State = Filled then
               null;
            else
               Enqueue(Smallest, SortedQueue);
            end if;

            KQueue := TempQueue;
            TempQueue := EmptyQueue;
            Dequeue(Smallest, KQueue);
         end if;   

      end loop;

Name: Anonymous 2009-01-20 22:09

>>            if SortedQueue.Top = SortedQueue.Free and SortedQueue.Queue_State = Filled then
               null;
            else
               Enqueue(Smallest, SortedQueue);
            end if;


lol

Name: Anonymous 2009-01-20 22:26

This is actually pretty decent.  Why are you using Ada?

Name: Anonymous 2009-01-20 22:37

>>3
To learn concurrency.  That's why I'm learning Ada anyway.  I have mostly just been using it to do stuff I would normally do in other languages so far.

Name: Anonymous 2009-01-21 0:48

SELECTION SORT

Name: Anonymous 2009-01-21 0:53

This is my quickSort in, yeah, you know.


qSort []     = []
qSort (x:xs) = qSort l ++ [x] ++ qSort h
    where (l,h) = partition (<x) xs

Name: Anonymous 2009-01-21 1:12

>>6
Works on lists, not queues.

Name: Anonymous 2009-01-21 2:35

dix

Name: Anonymous 2009-01-21 2:55

n butts

Name: Anonymous 2009-01-21 3:48

>>7
Because a queue and a list are totally different

Name: Anonymous 2009-01-21 4:23

>>10
Ya

Name: Anonymous 2009-01-21 8:27

Ada, also known as Smalltalk.

Name: Anonymous 2009-01-21 8:41

Now implement the same in VHDL on an FPGA.

Name: Anonymous 2009-01-21 9:05

I hate you /prog/

You are slow as hell

Name: Anonymous 2009-01-21 9:31

>>15
You are too fast

Name: Anonymous 2009-01-21 10:19

>>16
I invented that meme

Name: Anonymous 2009-01-21 19:16

>>14
Enjoy building all those datapaths and pipelining it

Name: Anonymous 2009-01-21 21:17

>>17
Please don't misuse memes!

Name: Anonymous 2009-01-22 3:33

>>10
Actually, for queues your code is slower than the OP because of the amount of shuffling ++ causes on queues.

Name: Anonymous 2009-01-28 18:31

Break that shit into separate functions ew

Name: Anonymous 2009-01-29 11:49

LOL, ADA.

Name: Anonymous 2009-01-29 15:20

i haev bonner

Name: Anonymous 2011-02-03 2:01


Don't change these.
Name: Email:
Entire Thread Thread List