#import <ObjectiveLib/List.h>
Inheritance diagram for OLList:
Public Member Functions | |
(void) | - assign:filledWith: |
Assign objects to the list. | |
(void) | - assignFrom:to: |
Assign a range of objects to the list. | |
(id) | - back |
Return the last object in the list. | |
(OLListIterator *) | - begin |
Return an iterator pointing to the beginning of the sequence. | |
(void) | - clear |
Remove all elements. | |
(int) | - compare: |
Compare this list to another object. | |
(id) | - copy |
Make a copy of this list. | |
(BOOL) | - empty |
Test whether the list is empty. | |
(OLListIterator *) | - end |
Return an iterator pointing to one position beyond the end of the sequence. | |
(OLListIterator *) | - erase: |
Remove the element designated by where. | |
(OLListIterator *) | - eraseFrom:to: |
Remove a range of elements. | |
(id) | - front |
Return the first object in the list. | |
(void) | - insertAt:count:filledWith: |
Insert a number of objects into the list. | |
(void) | - insertAt:from:to: |
Insert a range of objects into the list. | |
(OLListIterator *) | - insertAt:value: |
Insert an object into the list. | |
(BOOL) | - isEqual: |
Return whether this list is equal to another one. | |
(unsigned) | - maxSize |
Return the maxiumum number of objects that can be stored in a list. | |
(void) | - merge: |
Merge the contents of two lists. | |
(void) | - merge:withOrder: |
Merge the contents of two lists. | |
(void) | - popBack |
Remove the last element in the list. | |
(void) | - popFront |
Remove the first element in the list. | |
(void) | - pushBack: |
Insert object at the end of the sequence. | |
(void) | - pushFront: |
Insert object at the beginning of the sequence. | |
(OLReverseBidiIterator *) | - rbegin |
Return a reverse iterator pointing to the end of the sequence. | |
(void) | - remove: |
Remove all objects equal to object. | |
(void) | - removeIf: |
Remove all objects for which pred returns YES. | |
(OLReverseBidiIterator *) | - rend |
Return a reverse iterator pointing to the beginning of the sequence. | |
(void) | - resize:filledWith: |
Resize the list to newsize. | |
(void) | - reverse |
Reverse the order of the list. | |
(unsigned) | - size |
Return the number of elements in the list. | |
(void) | - sort |
Sort the list in ascending order. | |
(void) | - sortWith: |
Sort the list. | |
(void) | - spliceAt:list: |
Splice another list into this one. | |
(void) | - spliceAt:list:from: |
Splice an element from another list into this one. | |
(void) | - spliceAt:list:from:to: |
Splice a range of elements into this list. | |
(void) | - swap: |
Swap this list with another one. | |
(void) | - unique |
Remove all but one of each consecutive element in the list. | |
(void) | - uniqueWith: |
Remove all but one of each consecutive element for which pred returns YES. | |
(void) | - writeSelfToStream: |
Write the object to a stream. | |
Initializers and Deallocators | |
(id) | - free |
Finalize the list and deallocate any allocated memory. | |
(id) | - init |
Initialize the list. | |
(id) | - initFrom:to: |
Initialize the list. | |
(id) | - initWithList: |
Initialize the list. | |
(id) | - initWithObjectInStream: |
Initialize the object. | |
(id) | - initWithSize:filledWith: |
Initialize the list. | |
Static Public Member Functions | |
(id) | + list |
Create and return a new list. | |
(id) | + listFrom:to: |
Create and return a new list. | |
(id) | + listWithList: |
Create and return a new list. | |
(id) | + listWithSize:filledWith: |
Create and return a new list. | |
Protected Attributes | |
OLListNode * | node |
The head of the list. |
A sequence of elements that is a bidirectional linked list, and thus may be traversed both forwards and backwards. An important feature of lists is that insertion and removal do not affect existing iterators unless the iterator points directly to an object that has been removed. Due to the fact that some algorithms from OLAlgorithm require random access iterators and lists only provide bidirectional iterators, some messages are provided in OLList to make up for the unavailability of the functionality in OLAlgorithm. Examples of these messages include sort (OLList), unique (OLList) and merge: (OLList).
- (void) assign: | (unsigned) | count | ||
filledWith: | (id) | value | ||
Assign objects to the list.
The current contents of the list are removed, and the list is filled with count elements of value.
count | the number of elements to assign | |
value | the object to be copied into the list |
- (void) assignFrom: | (OLForwardIterator *) | first | ||
to: | (OLForwardIterator *) | last | ||
Assign a range of objects to the list.
The current contents of the list are removed, and all elements in the range [first, last)
are inserted into the list.
first | the first in the range of objects to assign | |
last | one beyond the last in the range of objects to assign |
- (id) back |
Return the last object in the list.
A reference to the object is returned, though the list still owns the object in question.
- (OLListIterator*) begin |
Return an iterator pointing to the beginning of the sequence.
- (void) clear |
Remove all elements.
- (int) compare: | (id) | other |
Compare this list to another object.
If the other object is of type OLList, each of the contained objects is compared to the corresponding object in other by calling the compare:
method.
other | the object with which to compare this one |
- (id) copy |
Make a copy of this list.
- (BOOL) empty |
Test whether the list is empty.
- (OLListIterator*) end |
Return an iterator pointing to one position beyond the end of the sequence.
- (OLListIterator*) erase: | (OLListIterator *) | where |
Remove the element designated by where.
where | an iterator designating the element to remove |
- (OLListIterator*) eraseFrom: | (OLListIterator *) | first | ||
to: | (OLListIterator *) | last | ||
Remove a range of elements.
All elements in the range [first, last)
will be removed from the list.
first | the first in the range of elements to remove | |
last | one position beyond the last in the range of elements to remove |
- (id) free |
Finalize the list and deallocate any allocated memory.
- (id) front |
Return the first object in the list.
A reference to the object is returned, though the list still owns the object in question.
- (id) init |
Initialize the list.
The resulting list will be empty.
- (id) initFrom: | (OLForwardIterator *) | first | ||
to: | (OLForwardIterator *) | last | ||
Initialize the list.
The list inserts all elements referred to in the range [first, last)
.
first | the first in the range of elements to insert | |
last | one beyond the last in the range of elements to insert |
- (id) initWithList: | (OLList *) | list |
Initialize the list.
All the elements of list are copied into the current list.
list | the list to copy |
- (id) initWithObjectInStream: | (OLObjectInStream *) | stream |
Initialize the object.
Each instance variable is read from stream and all other initialization is performed.
stream | the stream from which to read |
Reimplemented from < OLStreamable >.
- (id) initWithSize: | (unsigned) | size | ||
filledWith: | (id) | value | ||
Initialize the list.
The initial size of the list will be size, and value will be copied into the list size times.
size | the number of elements to insert | |
value | the object to be copied |
- (void) insertAt: | (OLListIterator *) | where | ||
count: | (unsigned) | num | ||
filledWith: | (id) | value | ||
Insert a number of objects into the list.
num objects of value will be inserted just before the position referred to by where. Thus, it is valid to use an iterator returned by end as an argument.
where | the position at which to insert the objects | |
num | the number of objects to insert | |
value | the object to be copied into the list |
- (void) insertAt: | (OLListIterator *) | where | ||
from: | (OLForwardIterator *) | first | ||
to: | (OLForwardIterator *) | last | ||
Insert a range of objects into the list.
All objects in the range [first, last)
are inserted just before the position referred to by where. Thus, it is valid to use an iterator returned by end as an argument.
where | the position at which to insert the objects | |
first | the first in the range of objects to insert | |
last | one position beyond the last in the range of objects to insert |
- (OLListIterator*) insertAt: | (OLListIterator *) | where | ||
value: | (id) | object | ||
Insert an object into the list.
The object will be inserted just before the position referred to by where. Thus, it is valid to use an iterator returned by end as an argument.
where | the position at which to insert object | |
object | the object to insert |
- (BOOL) isEqual: | (id) | object |
Return whether this list is equal to another one.
Two lists are considered equal if they both contain the same number of objects that all return YES to the message isEqual:
and they are in the same order.
object | the object to test |
Reimplemented from < OLBackInserter >.
+ (id) list |
Create and return a new list.
+ (id) listFrom: | (OLForwardIterator *) | first | ||
to: | (OLForwardIterator *) | last | ||
Create and return a new list.
The list is initialized with the contents of the range [first, last)
.
first | the first in the range of elements to insert | |
last | one beyond the last in the range of elements to insert |
+ (id) listWithList: | (OLList *) | right |
Create and return a new list.
The list is initialized with the contents of right.
right | the list with which to initialize the new one |
+ (id) listWithSize: | (unsigned) | size | ||
filledWith: | (id) | value | ||
Create and return a new list.
The list is initialized with a size of size and is filled with value.
size | the number of elements to insert | |
value | the object to be copied |
- (unsigned) maxSize |
Return the maxiumum number of objects that can be stored in a list.
This limit is theoretical, meaning that there is no guarantee that you can insert this many objects into any given list. The memory conditions of the run-time system play an important role.
- (void) merge: | (OLList *) | right |
Merge the contents of two lists.
Both lists must be sorted in ascending order. That is, they must be sorted using the function object OLLess, or with a function object that perfroms the same operation as OLLess. All elements are removed from right and inserted in order into this list. This is a stable merge in that if two elements are equal, the one from this list will precede the one from right after the merge.
right | the list to merge into this list |
- (void) merge: | (OLList *) | right | ||
withOrder: | (id< OLBoolBinaryFunction >) | pred | ||
Merge the contents of two lists.
Both lists must be sorted in the order defined by pred. All elements are removed from right and inserted in order into this list. This is a stable merge in that if two elements are equal, the one from this list will precede the one from right after the merge.
right | the list to merge into this list | |
pred | the function object that defines the sorting order |
- (void) popBack |
Remove the last element in the list.
- (void) popFront |
Remove the first element in the list.
- (void) pushBack: | (id) | object |
Insert object at the end of the sequence.
object | the object to insert |
Reimplemented from < OLBackInserter >.
- (void) pushFront: | (id) | object |
Insert object at the beginning of the sequence.
object | the object to insert |
Reimplemented from < OLFrontInserter >.
- (OLReverseBidiIterator*) rbegin |
Return a reverse iterator pointing to the end of the sequence.
Advancing the returned iterator will move backwards through the sequence to the point indicated by the iterator returned by rend.
- (void) remove: | (id) | object |
Remove all objects equal to object.
For each element in the list this message performs an equivilance check using the message isEqual:
, and if the check succeeds the element is removed from the list.
isEqual:
.object | the object with which to compare this list's members |
- (void) removeIf: | (id< OLBoolUnaryFunction >) | pred |
Remove all objects for which pred returns YES.
For each element in the list this message uses the function object pred to test the element. If the function object returns YES, then the element is removed from the list.
pred | the object to perform the check |
- (OLReverseBidiIterator*) rend |
Return a reverse iterator pointing to the beginning of the sequence.
This iterator indicates one position beyond the last position that may be referenced by a reverse iterator.
- (void) resize: | (unsigned) | count | ||
filledWith: | (id) | value | ||
Resize the list to newsize.
If newsize is smaller than the current size, then the sequence will be truncated. If newsize is larger than the current size, then value will be inserted at the end of the list as many times as necessary to fill the new size.
count | the new size of the list | |
value | the value with which to fill new elements, if necessary |
- (void) reverse |
Reverse the order of the list.
The elements are placed in reverse order.
- (unsigned) size |
Return the number of elements in the list.
- (void) sort |
Sort the list in ascending order.
The function object OLLess is used to compare elements in the list to establish the order.
- (void) sortWith: | (id< OLBoolBinaryFunction >) | pred |
Sort the list.
The function object pred is used to compare elements in the list to establish the order.
pred | the object used to compare elements |
- (void) spliceAt: | (OLListIterator *) | where | ||
list: | (OLList *) | right | ||
Splice another list into this one.
All elements are removed from right and inserted just before the element pointed to by where.
where | the position at which to perform the splice | |
right | the list to splice to this one |
- (void) spliceAt: | (OLListIterator *) | where | ||
list: | (OLList *) | right | ||
from: | (OLListIterator *) | first | ||
Splice an element from another list into this one.
The element pointed to by first is removed from right and inserted into this list just before where.
where | the position at which to perform the splice | |
right | the list that contains first | |
first | the element in right to splice into this list |
- (void) spliceAt: | (OLListIterator *) | where | ||
list: | (OLList *) | right | ||
from: | (OLListIterator *) | first | ||
to: | (OLListIterator *) | last | ||
Splice a range of elements into this list.
The elements in the list right in the range [first, last)
are removed from right and inserted into this list just before the element pointed to by where.
where | the position at which to perform the splice | |
right | the list that contains first and last | |
first | the first element in the range to splice | |
last | one position beyond the last element in the range to splice |
- (void) swap: | (OLList *) | right |
Swap this list with another one.
All elements in right will be placed into this list, and all elements in this list will be placed in right.
right | the list with which to swap this one |
- (void) unique |
Remove all but one of each consecutive element in the list.
The first of equivilent elements is retained, and the others are removed. This message will only be useful if the list is sorted first, as only consecutive elements are compared.
- (void) uniqueWith: | (id< OLBoolBinaryFunction >) | pred |
Remove all but one of each consecutive element for which pred returns YES.
For any two consecutive elements for which pred returns YES only the first is retained in the list. All others are removed.
pred | the function to use to compare list elements |
- (void) writeSelfToStream: | (OLObjectOutStream *) | stream |
Write the object to a stream.
All instance variables are written to stream.
stream | the stream to which to write. |
Reimplemented from < OLStreamable >.
- (OLListNode*) node [protected] |
The head of the list.
|