This class extends GSLinkedList by providing storage for
unused links and re-using those links when a new link
is needed. This avoids the overhead of
allocating/deallocating links and
provides an API more like a mutable array.
Creates an instance of a store to be used to create
links using the specified class (must be a subclass
of GSListLink). If the class is nil then
GSListLink is used.
Adds an object at the tail of the list (calls
-insertObject:after:), making it the
last object in the list. Returns the list link
that the object is stored in.
Inserts anObject immediately after the
specified link. If at is
nil the object is inserted
at the end of the list (as tail).
Returns the list link that the object is stored in.
Inserts anObject immediately before the
specified link. If at is
nil the object is inserted
at the start of the list (as head).
Returns the list link that the object is stored in.
GSLinkedList manages a list of GSListLink
objects. The notional direction of the list
is from head to tail. So the head is considered to be the
first link in the list and tail is considered to be the
last (head is before tail, tail is after head).
Searches the linked list returning the link
containing object or nil
if it is not found. The comparison is performed
using the
[NSObject -isEqual:]
method of object. If
start is nil then the whole
list is searched. This method will not
find links containing nil items.
Searches the linked list returning the link
containing object or nil
if it is not found. If start is
nil then the whole list is searched.
A direct pointer comparison is used to
determine equality.
GSListLink provides simple doubly linked list
functionality to avoid the need to constantly
re-invent it (as the OpenStep/Cocoa APIs do not
provide this). The emphasis is on speed of operation
so instance variables are directly accessible and inline
functions are provided to manipulate them (without
error cehcking), but you can/should avoid these direct
access features unless speed is really critical.
A list may either be 'normal'... (where the
head/tail ends of the list have a nil
pointer to the previous/next link) or 'circular' in
which case the list is not terminated. The
GSListLink item carries a minimal payload of a
single item which is retained by the link. The
GSListLink owner is an optional pointer to an
object which 'owns' the link... a GSLinkedList
instance may use this to check link ownership when
manipulating links.
Inserts link after at in a
circular list. Arguments must not be
nil and link must not be in a
list (ie its next and previous pointers must point to
itsself).
Inserts link before at in a
circular list. Arguments must not be
nil and link must not be in a
list (ie its next and previous pointers must point to
itsself).
Inserts link before at in a
normal list. Arguments must not be
nil and link must not be in a
list (ie its next and previous pointers must both be
nil).
Searches fromlist to the end
looking for the first link containing
object (as determined by using object's
[NSObject -isEqual:]
method). If back is
YES, the search is in the direction
from tail to head rather than the normal
search from head to tail. If
from is nil the list
is search from head or tail as appropriate to
the direction in which it is searched.
Searches fromlist to the end
looking for the first link containing
object (as determined by direct pointer
comparison). If back is
YES, the search is in the direction
from tail to head rather than the normal
search from head to tail. If
from is nil the list
is search from head or tail as appropriate to
the direction in which it is searched.
Inserts link immediately after
at. If at is
nil, inserts at the end of the
list (link becomes tail).
Updates the head, tail and count variables of
list. Does not retain link
.
Inserts link immediately before
at. If at is
nil, inserts at the start of
the list (link becomes head).
Updates the head, tail and count variables of
list. Does not retain link
.