swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

List vs. Linked List???


From: glen e. p. ropella
Subject: List vs. Linked List???
Date: Wed, 24 Sep 1997 18:37:56 -0600

address@hidden writes:
 > Is there such thing as a straight List.  I am using a List in my
 > simulation.  But, when I try to use removeFirst or removeLast, I get
 > tons of errors, it may be other causes.  But, are there any documents
 > (beside the Swarm1.0.2, or gridturtles) which explain and (give examples
 > for), all types of collections?
 > 
 > Its a little confusing, is there any "Lists" of all the various
 > collection types, and what methods they can use?  Not the "planned", but
 > the currently usable methods. 

The best list of collections is right there in the src/collections/
library.  I have:

grasshopper[7]% ls src/collections/
Array.h         List.m          List_mlinks.m   OrderedSet.o    String.m
Array.m         List.o          List_mlinks.o   OutputStream.h  String.o
Array.o         List_GEN.h      Makefile        OutputStream.m  collections.h
CVS/            List_GEN.m      Map.h           OutputStream.o  collections.m
Collection.h    List_linked.h   Map.m           Set.h           collections.o
Collection.m    List_linked.m   Map.o           Set.m           collections.xc
Collection.o    List_linked.o   OrderedSet.h    Set.o           collections.xm
List.h          List_mlinks.h   OrderedSet.m    String.h        collections.xt

Which translates to Array, List, List_linked, Map, OrderedSet, OutputStream,
Set, and String.  You can get the interface for each from the collection.h
file.  I realize that "RTFSC" is not a good answer to this question....
[grin]  But, it's the finest source available for what's in Swarm.

 > Maybe the List type isn't the best option (as far as collections go),
 > here are my needs:
 > 
 > Be sortable.
 > Easy to traverse.
 > Easy to add and remove members.
 > Easy to use pointers to access different members.

It's reasonable for you to use a Map, I would guess, if the "sortability"
you need is just for one value (the key).  If, however, you want to 
sort for more than one attribute that is resident in the body of the
objects on the list, then just a plain old list is the best we got.

However, this doesn't stop you from writing your own collection that
has, say 5 keys prioritized in some way.  My guess is that it would be
akin to a Set.  "Set is a subtype of KeyedCollection in which the key
value associated with each member is determined by the member value
itself. The key value may be identical to the member itself, or may be
defined as a a function of the member using a create-time option."
So, you could instantiate a set and fill it with objects that know
which attribute (or whatever else) is relevant based on a call to a
function they've defined.  But, you only need this in the case that
"sortable" is a complex property for you.

glen
-- 
{glen e. p. ropella <address@hidden> |  Send lawyers, guns, and money!  }
{Hive Drone, SFI Swarm Project         |            Hail Eris!            }
{http://www.trail.com/~gepr/home.html  |               =><=               }

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]