Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Eiffel > Re: Creation of...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 891 of 913
Post > Topic >>

Re: Creation of arrays with complex types

by Jean RUPPERT <ruppertj@[EMAIL PROTECTED] > Oct 24, 2007 at 10:08 PM

Sorry, I have not been coding in the wonderful eiffel language
since some time, so it might be impossible to compile what I write,
but I think a loop will do the job:

  bucket_sort is
              -- Sort array.
          local
              buckets: ARRAY [LINKED_LIST [G]]
              bucket: LINKED_LIST [G]
              i,last: INTEGER
          do
              last:=4 -- last could also be set by another
                      -- method and not be local
              create buckets.make (0,last)
              from i:=0 until i>last
              loop
                 create bucket.make
                 buckets.item(i) := bucket
              end --loop
          end --bucket_sort

Roman Töngi a écrit :
> Is it possible to create an ARRAY [LINKED_LIST [G]] more elegantly  in a

> single step? If the number of array-elements is not known in advance, is

> there a dynamic version?
> 
>     bucket_sort is
>             -- Sort array.
>         local
>             buckets: ARRAY [LINKED_LIST [G]]
>             bucket_0: LINKED_LIST [G]
>             bucket_1: LINKED_LIST [G]
>             bucket_2: LINKED_LIST [G]
>             bucket_3: LINKED_LIST [G]
>             bucket_4: LINKED_LIST [G]
>         do
>             create buckets.make (0, 4)
>             create bucket_0.make
>             create bucket_1.make
>             create bucket_2.make
>             create bucket_3.make
>             create bucket_4.make
>             buckets.item (0) := bucket_0
>             buckets.item (1) := bucket_1
>             buckets.item (2) := bucket_2
>             buckets.item (3) := bucket_3
>             buckets.item (4) := bucket_4
>         end
> 
> 
> Many thanks
> Roman




 3 Posts in Topic:
Creation of arrays with complex types
=?ISO-8859-1?Q?Roman_T=F6  2007-10-24 18:40:00 
Re: Creation of arrays with complex types
Jean RUPPERT <ruppertj  2007-10-24 22:08:29 
Re: Creation of arrays with complex types
=?ISO-8859-1?Q?Roman_T=F6  2007-10-24 23:31:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 22:07:06 CDT 2008.