Developer Documentation |
RAVL, Recognition And Vision Library |
FixedQueueC<class T>
|
|
Fixed size circular queue.
|
|
include | "Ravl/FixedQueue.hh" |
Created: | 6/6/97 |
Source file: | Ravl/Core/Container/Queue/FixedQueue.hh |
User Level: | Normal |
Library: | RavlCore |
In Scope: | RavlN |
Comments:
A SMALL object.
This is sometimes known as a ring buffer.
FIXME :- Make FixedQueueC big.
FIXME :- Speed up, use ptr's!.
Note, this does not destroy items removed from
the queue until the element is overwritten by another.
Parent Classes:
Variables:
- T * head;
-
Next free location.
- T * tail;
-
Last used location.
- T * eoa;
-
Ptr to end of array.
Methods:
- FixedQueueC(SizeT Size)
-
Constructor.
- bool IsSpace()
-
Is space to data into ring ?
- void InsLast(const T & Obj)
-
Insert data at end of queue.
returns the place its index in the array.
- void ForceInsLast(const T & Obj)
-
Insert data at end of queue, if no space discard oldest element.
returns the place its index in the array.
- bool IsEmpty() const
-
Is ring empty ?
- T GetFirst()
-
Get first item from queue.
- const T & First() const
-
Access first the first element in the queue.
- T & First()
-
Access first the first element in the queue.
- T & Last()
-
Look at the item most recently placed in the queue.
- const T & Last() const
-
Look at the item most recently placed in the queue.
- void DelFirst()
-
Delete thing in buffer
- SizeT Size() const
-
No of items in the ring.
- SizeT MaxSize() const
-
Get maximum size of queue.
- bool IsInRing(UIntT P) const
-
Is P an index in the ring.
- void Empty()
-
Empty the queue of all contents.
Reset to head=0, tail=0
Constructors, assigment, and destructor
- SArray1dC<T> Copy() const
-
Creates a new physical copy of the array.
- SArray1dC<T> Copy(UIntT extend) const
-
Creates a new physical copy of the array.
'extend' extra elements initalised by the default constuctor
are appended to the end of the array.
- void CopyFrom(const Slice1dC<T> & slice)
-
Copy contents of slice into array.
The first element of the slice is copied to element
0 of this array, second to 1 etc. If this array isn't
large enough an exception is thrown.
- const SArray1dC<T> & operator =(const SArray1dC<T> & vv)
-
Assign this handle to the data in VV.
- SArray1dC<T> operator +(const SArray1dC<T> & arr) const
-
Sums 2 numerical arrays.
The operator returns the result as a new array.
- SArray1dC<T> operator -(const SArray1dC<T> & arr) const
-
Subtract 2 numerical arrays.
The operator returns the result as a new array.
- SArray1dC<T> operator *(const SArray1dC<T> & arr) const
-
Mutliplies 2 numerical arrays.
The operator returns the result as a new array.
- SArray1dC<T> operator /(const SArray1dC<T> & arr) const
-
Divides 2 numerical arrays.
The operator returns the result as a new array.
- SArray1dC<T> operator *(const T & number) const
-
Multiplys the array by the 'number'.
The operator returns the result as a new array.
- SArray1dC<T> operator /(const T & number) const
-
Divides all array items by the 'number'.
The operator returns the result as a new array.
- SArray1dC<T> operator +(const T & number) const
-
Adds 'number' to the array.
The operator returns the result as a new array.
- SArray1dC<T> operator -(const T & number) const
-
Subtracts 'number' from all array items.
The operator returns the result as a new array.
- const SArray1dC<T> & operator +=(const SArray1dC<T> & arr)
-
Adds the 2nd array to this array.
- const SArray1dC<T> & operator -=(const SArray1dC<T> & arr)
-
Subtracts the 2nd array from this array.
- const SArray1dC<T> & operator *=(const SArray1dC<T> & arr)
-
Multiplies the 2nd array to this array.
- const SArray1dC<T> & operator /=(const SArray1dC<T> & arr)
-
Divides the 2nd array from this array.
- const SArray1dC<T> & operator +=(const T & number)
-
Adds 'number' to all array items.
- const SArray1dC<T> & operator -=(const T & number)
-
Subtracts 'number' from all array items.
- const SArray1dC<T> & operator *=(const T & number)
-
Multiplies the array by the 'number'.
- const SArray1dC<T> & operator /=(const T & number)
-
Divides the array elements by the 'number'.
- T Sum() const
-
Calculate the sum of all elements in the array
- T SumSqr() const
-
Calculate the sum of the squares of all elements in the array
Access to the object and its parts.
- const SArray1dC<T> & SArray1d() const
-
Access to the whole constant array.
- SArray1dC<T> & SArray1d()
-
Access to the whole array.
- Slice1dC<T> Slice1d()
-
Access array as a slice.
Modifications of the representation
- SArray1dC<T> & Append(const SArray1dC<T> & a)
-
This array is extended by the length of the array 'a' and the contents
of both arrays are copied to it. Empty arrays are handled correctly.
- SArray1dC<T> Join(const SArray1dC<T> & Oth) const
-
Join this Array and another into a new Array which
is returned. This does not change either of its arguments.
This is placed in the array first, followed by 'Oth'.
- SArray1dC<T> From(UIntT offset)
-
Return array from offset to the end of the array.
If offset is larger than the array an empty array
is returned,
- SArray1dC<T> From(UIntT offset,UIntT size)
-
Return array from offset to the end of the array.
If offset is larger than the array an empty array
is returned,
- SArray1dC<T> After(UIntT offset)
-
Return array after offset to the end of the array.
If offset is larger than the array an empty array
is returned,
Special operations
- BufferC<T> & Buffer()
-
Access base data buffer.
Experts only.
- const BufferC<T> & Buffer() const
-
Constant access base data buffer.
Experts only.
- void Sort()
-
Sort the array in place.
This does a simple bubble sort.
FIXME:- we could do with something better!
- bool operator ==(const SArray1dC<T> & vv)
-
Comparison operator
Returns true if the two arrays are the same length and
their contents are identical.
- UIntT Hash() const
-
Compute a hash value for the array.
- T * DataStart() const
-
Returns the address of element 0.
If the array has zero length a null pointer may
be returned.
- const SizeBufferAccessC<T> & operator =(T * bp)
-
Changes the reference element to the element pointed by 'bp'.
Access to the object
--------------------
- T * DataStart() const
-
Returns the address of the first element of the buffer.
- SizeT Size() const
-
Returns the number of elements of the array.
- IndexRangeC Limits() const
-
Returns the usable range of indeces expressed by this object.
- IndexRangeC Range() const
-
Returns the usable range of indeces expressed by this object.
- IndexC IMin() const
-
Returns the minimum index of the range of this access.
- IndexC IMax() const
-
Returns the maximum index of the range of this access.
- const T & operator [](const IndexC i) const
-
Read-only access to the ('i'+1)-th element of the buffer.
- T & operator [](const IndexC i)
-
Read-write access to the ('i'+1)-th element of the buffer.
- const SizeBufferAccessC<T> & SAccess(void) const
-
Returns this object.
Logical functions
-----------------
- bool IsEmpty() const
-
Returns TRUE if the size of the array is zero.
- bool Contains(IndexC i) const
-
Returns TRUE if the array contains an item with the index 'i'.
Modifications of the access
---------------------------
- SizeT ShrinkHigh(SizeT k)
-
Changes the number of elements by subtracting the last 'k' elements.
- const SizeBufferAccessC<T> & Swap(SizeBufferAccessC<T> & a)
-
Exchanges the contents of this buffer with buffer 'a'.
- void Attach(const SizeBufferAccessC<T> & b)
-
Changes this buffer access to have the same access rights as 'b'.
- void Attach(const BufferAccessC<T> & b,SizeT size)
-
Changes this buffer access to have the access rights as 'b' limited
for 'size' elements.
- SizeBufferAccessC<T> operator +(SizeT i) const
-
Creates the new access object shifted 'i' elements to the right
(towards next elements). The size is descreased to fit the
the original range of this access.
Modifications of the buffer contents
------------------------------------
- void Fill(const T & d)
-
'd' value is assigned to all elements of the buffer.
- void CopyFrom(const SizeBufferAccessC<T> & oth)
-
Copy contents of another buffer into this one.
NB. Buffers MUST be the same length.
- void Reverse()
-
Reverse the order of elements in this array in place.
- SizeBufferAccessC<T> BufferFrom(UIntT first)
-
Get an access for this buffer starting from the 'first' element to the end of the buffer.
- SizeBufferAccessC<T> BufferFrom(UIntT first,UIntT len)
-
Get an access for this buffer starting from the 'first' element for 'len' elements.
An error will be generated if the requested buffer isn't contains within this one.
- bool operator ==(const SizeBufferAccessC<T> & ba) const
-
Are two accesses the same ?
- SizeBufferAccessC<T> Copy(void) const
-
Returns a physical copy of this access pointing to the physical
copy of the accessed buffer in the range accessible by this access.
The new copy is necessary to attach to reference counted buffer
or to delete at the end of the life of this object.
- T * ReferenceElm() const
-
Returns the pointer to the reference element of the attached buffer.
The reference element need not to be the valid element of the buffer.
- void * ReferenceVoid() const
-
Returns the pointer to the reference element of the attached buffer.
The reference element need not to be the valid element of the buffer.
The function is intended to be used in printing.
- bool IsValid() const
-
Returns TRUE if this buffer access is not a default access object.
- const T & operator [](const IndexC i) const
-
Read-only access to the ('i'+1)-th element of the buffer.
- T & operator [](const IndexC i)
-
Read-write access to the ('i'+1)-th element of the buffer.
- const BufferAccessC<T> & operator +=(IndexC ind)
-
Inplace Add index to start position.
- const BufferAccessC<T> & operator -=(IndexC ind)
-
Inplace Subtract index from start position.
- BufferAccessC<T> operator -(IndexC ind) const
-
Substract value from position, and return it as a new value.
- BufferAccessC<T> operator +(IndexC ind) const
-
Substract value from position, and return it as a new value.
- bool operator ==(const BufferAccessC<T> & ba) const
-
Are two accesses the same ?
- bool operator !=(const BufferAccessC<T> & ba) const
-
Are two accesses the same ?
Maintainer:Charles Galambos, Created: 6/6/97, Documentation by CxxDoc: Tue Aug 13 09:59:30 2002
|