1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * list.h: a non-sucky linked list implementation
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2007 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
32 typedef bool (* NodeAction
) (Node
*node
, void *data
);
45 Node
*First () { return head
; }
51 void Clear (bool freeNodes
);
53 Node
*Append (Node
*node
);
54 Node
*Prepend (Node
*node
);
55 Node
*Prepend (List
*list
);
56 Node
*Insert (Node
*node
, int index
);
57 Node
*InsertAfter (Node
*node
, Node
*after
);
58 Node
*InsertBefore (Node
*node
, Node
*before
);
60 Node
*Replace (Node
*node
, int index
);
62 Node
*Find (NodeAction find
, void *data
);
63 void Remove (NodeAction find
, void *data
);
64 void Remove (Node
*node
);
65 void RemoveAt (int index
);
66 void Unlink (Node
*node
);
68 Node
*Index (int index
);
70 int IndexOf (Node
*node
);
71 int IndexOf (NodeAction find
, void *data
);
73 void ForEach (NodeAction action
, void *data
);
85 // convenience properties
89 // convenience methods
90 void Clear (bool freeNodes
);
92 void Push (List::Node
*node
);
98 // accessing the internal linked list directly requires manual Locking/Unlocking.
101 // copies the queue and empties the original
102 void MoveTo (Queue
&queue
);
108 int size
; // size of array
109 int count
; // # of items in the array
115 int GetCount () { return count
; }
116 void SetCount (int value
);
119 void SetCapacity (int value
);
121 void EnsureCapacity (int capacity
);
122 int Add (void *item
);
123 void *& operator [] (int index
) { return array
[index
]; }
126 #endif /* __LIST_H__ */