- Inherits from:
- Object
- Conforms to:
- DQueuable, DStackable
- Declared in:
- DCircle.h
Object
|
+---DCircle
Class Description
The circular buffer collection stores objects in an circular buffer that can grow.
Objects can be read by an index, which can be negative for accessing elements from
the end. This collection can be used for implementing a queue (FIFO) or a stack (LIFO).
- Last modified:
- 23-Jul-2006 (DCircle.h)
Instance Variables
- private id *_objects
- the stored objects
- private long _size
- the size of the buffer
- private long _first
- the first element in the buffer (or -1 for empty)
- private long _next
- the next element in the buffer
- Constructors
- - (DCircle *) init
- Initialise to an empty buffer
- Returns:
- the object
- - (DCircle *) init :(long) size
- Initialise to a circular buffer with an initial size
- Parameters:
- size - the size of the buffer
- Returns:
- the object
- Copy related methods
- - deepen
- Deepen a copy of the buffer
- Returns:
- the object
- - shallowCopy
- Do a shallow copy of the object
- Returns:
- the object
- Destructor
- - free
- (Deep) free the buffer (incl. the stored objects)
- Returns:
- the object
- - shallowFree
- Free the buffer, not the stored objects
- Returns:
- the object
- Member methods
- - (BOOL) isEmpty
- Check if the buffer is empty
- Returns:
- is it ?
- - (BOOL) isFull
- Check if the buffer is full
- Returns:
- is it ?
- - (long) length
- Return the number of stored objects
- Returns:
- the length
- - (long) size
- Return the size of the buffer
- Returns:
- the size
- - (DCircle *) size :(long) size
- Set the size for the buffer
- Parameters:
- size - the new, larger size
- Returns:
- the object
- Index methods
- - (id) get :(long) index
- Return a reference to the indexth object
- Parameters:
- index - the index
- Returns:
- the object (or nil if invalid index)
- - (BOOL) isValid :(long) index
- Check if an index is valid
- Parameters:
- index - the index
- Returns:
- is it valid ?
- Stack/LIFO methods
- - (id) pop
- Pop an object from the stack (LIFO)
- Returns:
- the object (or nil if empty)
- - (BOOL) push :(id) obj
- Push an object on the stack (LIFO)
- Parameters:
- obj - the object to be pushed
- Returns:
- success (or buffer full)
- - (id) tos
- Return the object on top of the stack (LIFO)
(without changing the top of the stack)
- Returns:
- the object (or nil if empty)
- Queue/FIFO Methods
- - (id) dequeue
- Get an object from the queue (FIFO)
- Parameters:
- obj - the object
- Returns:
- the object (or nil for buffer empty)
- - (BOOL) enqueue :(id) obj
- Put an object in the queue (FIFO)
- Parameters:
- obj - the object
- Returns:
- success (or buffer full)
- Selector methods
- - (DCircle *) each :(SEL) sel
- Perform a selector on each object in the circular buffer,
starting from the first item in the buffer
- Parameters:
- sel - the selector
- Returns:
- the object
- - (DCircle *) reach :(SEL) sel
- Perform a selector on each object in the circular buffer,
starting from the last item in the buffer
- Parameters:
- sel - the selector
- Returns:
- the object
generated 25-Jul-2006 by ObjcDoc 3.0.0