swarm-support
[Top][All Lists]
Advanced

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

Re: Linked Lists


From: Roger Burkhart
Subject: Re: Linked Lists
Date: Tue, 30 Jan 96 08:13:46 MST

> I want to have a linked list where I can insert
> front or back.  (I have already been successful
> to this point.)  What I also need is to be able
> to traverse the list non-destructivly and delete
> either with a search or directly with a pointer
> access.  Are there functions already defined that 
> do this?  

Provided you are traversing the list with an index, you can remove
the member at the current index using [index remove].  This removes
the member, frees the associated link, and returns the member just
removed without freeing it.

Once you have an index, you can move it forward (next) or backward (prev)
until you are at a member of interest.  You can also set it an integer
relative position ([index setOffset: offset]) but this is not a fast
operation on the default list implementation.

There is no way to position directly to a standard link using a pointer to a
link, since the link isn't a real object for which an object id could be
externalized.  What you can do is allocate a space for the link inside the
member and declare the internal location of this link when you create the
list.  With this technique, you essentially provide your own object to serve
as the link object, which gives lots of flexibility and lets you keep a
pointer to such link objects wherever you want.  The same link object can
also be threaded into multiple lists, using links at different internal
locations.

The precise messages for positioning an index to a user-supplied link object
are currently in process of change as part of cleanup of the collections
interface.  Documentation has been delayed too long as part of these interface
revisions, brought about in part by uses of collections in the activity
implementation.

> Is there any further documentation availabe?

As JJ suggested, the test programs in apps/grid have been serving as
the only examples of list usage.  More is overdue.  Something is needed
before I leave SFI this week, but will need to be coordinated with a
release upgrade as well.

In the meantime, grid2b has the one example of a link embedded in a member,
outside of the activity library which uses them heavily, not least for every
action inside every action plan.  But currently that interface requires
creating a new index positioned directly to the desired member, using a
message createIndex:fromMember:.  This interface will be changing to support
a [index setMember: aMember] message on an index into an OrderedSet
collection (since each link must be a unique member of the collection).
But the other is usable for right now, modulo pending name changes.

Roger


reply via email to

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