Typed vector of pointers to T. More...
#include <SgVector.h>
Public Member Functions | |
T * | operator[] (int index) const |
Return const reference to element. | |
T * | Back () const |
Returns the last element of the vector. | |
bool | Contains (const T *element) const |
void | Include (const T *element) |
Push elt to the back of the vector unless it is already included. | |
bool | Exclude (const T *element) |
void | Exclude (const SgVectorOf< T > &vector) |
T * | Front () const |
Returns the first element of the vector. | |
bool | Insert (const T *element) |
void | PushFront (const T *element) |
void | PushBack (const T *element) |
T * | PopFront () |
Remove element[0] of the vector. | |
void *& | operator[] (int index) |
Return reference to element. | |
bool | operator== (const SgVector< void * > &rhs) const |
Compare whether the contents of two vectors are identical. | |
bool | operator!= (const SgVector &rhs) const |
Compare whether the contents of two vectors are not identical. | |
void * | BackAndPop () |
void | Clear () |
Remove all elements in this vector. | |
void | Concat (SgVector< void * > *tail) |
Push all of *tail to the back of this vector, and clear the *tail vector. | |
bool | Contains (const void *&elt) const |
Check if element is in vector. | |
void | DeleteAt (int index) |
delete element at specified index | |
bool | Exclude (const void *&elt) |
Remove the first occurence of element. | |
void | Exclude (const SgVector< void * > &vector) |
Exclude each element of vector from this vector. | |
int | Index (const void *&elt) const |
Find position of element. | |
void | Include (const void *&elt) |
Push elt to the back of the vector only if it is not included yet. | |
bool | Insert (const void *&elt) |
Includes the element in a ascending sorted vector at the right place. | |
bool | IsEmpty () const |
Return whether this vector contains zero elements. | |
bool | IsLength (int length) const |
Test whether a vector is as long as a given length. | |
bool | IsSorted (bool ascending=true) const |
Returns whether the vector is sorted in given order. | |
bool | IsSortedAndUnique (bool ascending=true) const |
Returns whether the vector is sorted and has no duplicates. | |
int | Length () const |
Return the number of elements in this vector. | |
void | LimitListLength (int limit) |
Cut off vector after at most length elements. | |
bool | MaxLength (int length) const |
Test whether a vector is shorter than or equal to a given length. | |
void | Merge (const SgVector< void * > &vector) |
Merges two sorted vectors into this. | |
bool | MinLength (int length) const |
Test whether a vector is as long as or longer than a given length. | |
bool | NonEmpty () const |
Return whether this vector contains more than zero elements. | |
void | PopBack () |
Remove the last element of the vector. | |
void | PushFront (const void *&elt) |
Insert element at the beginning of the vector. | |
void | PushBack (const void *&elt) |
Add a single element at the end of the vector. | |
void | PushBackList (const SgVector< void * > &vector) |
Push all elements from vector to the back of this. | |
bool | RemoveDuplicates () |
Removes all but the first copy of each element from the vector. | |
void | Reverse () |
void | SetTo (const void *&elt) |
Clear this vector and set it to contain only elt . | |
void | SetTo (const void **array, int count) |
Clear this vector and set it to contain the count elements from array[0] to array[count - 1] . | |
bool | SetsAreEqual (const SgVector< void * > &other) const |
Do vectors contain the same elements, possibly in different order? | |
void | Sort () |
void | SortedRemoveDuplicates () |
remove duplicates in a sorted vector | |
void | SwapWith (SgVector< void * > *vector) |
Swap the entire contents of this vector with *vector . | |
const void *& | TopNth (int index) const |
Returns the Nth-last element of the vector. | |
void | Union (const SgVector< void * > &set) |
Include all elements from set into this vector. | |
bool | UniqueElements () const |
Check for duplicate elements. | |
std::vector< void * > & | Vector () |
const std::vector< void * > & | Vector () const |
Static Private Member Functions | |
static void * | GetVoidPtr (const T *element) |
Conversion of element pointer to non-const void pointer. |
Typed vector of pointers to T.
Pointers cannot be 0.
Definition at line 344 of file SgVector.h.
T* SgVectorOf< T >::Back | ( | ) | const |
Returns the last element of the vector.
Asserts if the vector is empty.
Reimplemented from SgVector< void * >.
Definition at line 354 of file SgVector.h.
Referenced by SgVectorOf< std::string >::Back().
void * SgVector< void * >::BackAndPop | ( | ) | [inherited] |
Definition at line 64 of file SgVector.h.
References SgVector< T >::m_vec, SgVector< T >::NonEmpty(), SgVector< T >::PopBack(), and SG_ASSERT.
void SgVector< void * >::Clear | ( | ) | [inherited] |
Remove all elements in this vector.
Definition at line 73 of file SgVector.h.
References SgVector< T >::m_vec.
Referenced by FreeAll(), SgNode::PathToRoot(), SgGameReader::ReadGames(), and SgNode::ShortestPathTo().
Push all of *tail
to the back of this vector, and clear the *tail
vector.
Remark: this operation is efficient for lists but not so meaningful for vectors. PushBackList may be more appropriate in most cases.
bool SgVector< void * >::Contains | ( | const void * & | elt | ) | const [inherited] |
Check if element is in vector.
true
if elt
is included in this vector, false
if not. bool SgVectorOf< T >::Contains | ( | const T * | element | ) | const |
Definition at line 359 of file SgVector.h.
Referenced by SgVectorOf< std::string >::Contains(), and SgVectorOf< std::string >::Include().
void SgVector< void * >::DeleteAt | ( | int | index | ) | [inherited] |
delete element at specified index
bool SgVectorOf< T >::Exclude | ( | const T * | element | ) |
Definition at line 374 of file SgVector.h.
Referenced by SgVectorOf< std::string >::Exclude(), SgPropList::MoveToFront(), and SgPropList::Remove().
bool SgVector< void * >::Exclude | ( | const void * & | elt | ) | [inherited] |
Remove the first occurence of element.
If elt
is in the vector, remove the first occurence of elt
from the vector, and return true
. Otherwise do nothing and return false
.
Exclude each element of vector
from this vector.
void SgVectorOf< T >::Exclude | ( | const SgVectorOf< T > & | vector | ) |
Definition at line 379 of file SgVector.h.
T* SgVectorOf< T >::Front | ( | ) | const |
Returns the first element of the vector.
Asserts if the vector is empty.
Reimplemented from SgVector< void * >.
Definition at line 384 of file SgVector.h.
Referenced by SgVectorOf< std::string >::Front().
static void* SgVectorOf< T >::GetVoidPtr | ( | const T * | element | ) | [static, private] |
Conversion of element pointer to non-const void pointer.
Definition at line 429 of file SgVector.h.
Referenced by SgVectorOf< std::string >::Contains(), SgVectorOf< std::string >::Exclude(), SgVectorOf< std::string >::Insert(), SgVectorOf< std::string >::PushBack(), and SgVectorOf< std::string >::PushFront().
void SgVectorOf< T >::Include | ( | const T * | element | ) |
Push elt
to the back of the vector unless it is already included.
Definition at line 367 of file SgVector.h.
Referenced by SgPropList::Add().
void SgVector< void * >::Include | ( | const void * & | elt | ) | [inherited] |
Push elt
to the back of the vector only if it is not included yet.
Definition at line 118 of file SgVector.h.
References SgVector< T >::Contains(), and SgVector< T >::PushBack().
int SgVector< void * >::Index | ( | const void * & | elt | ) | const [inherited] |
Find position of element.
elt
in the vector, in range 0..length-1
. Returns -1 if elt
is not in the vector. bool SgVectorOf< T >::Insert | ( | const T * | element | ) |
Definition at line 389 of file SgVector.h.
Referenced by SgVectorOf< std::string >::Insert().
bool SgVector< void * >::Insert | ( | const void * & | elt | ) | [inherited] |
Includes the element in a ascending sorted vector at the right place.
Does nothing and returns false
if the element is already in the vector; returns true
if the element is inserted.
bool SgVector< void * >::IsEmpty | ( | ) | const [inherited] |
Return whether this vector contains zero elements.
Definition at line 134 of file SgVector.h.
References SgVector< T >::m_vec.
bool SgVector< void * >::IsLength | ( | int | length | ) | const [inherited] |
Test whether a vector is as long as a given length.
Definition at line 140 of file SgVector.h.
References SgVector< T >::Length().
bool SgVector< void * >::IsSorted | ( | bool | ascending = true |
) | const [inherited] |
Returns whether the vector is sorted in given order.
bool SgVector< void * >::IsSortedAndUnique | ( | bool | ascending = true |
) | const [inherited] |
Returns whether the vector is sorted and has no duplicates.
int SgVector< void * >::Length | ( | ) | const [inherited] |
Return the number of elements in this vector.
Definition at line 152 of file SgVector.h.
References SgVector< T >::m_vec.
void SgVector< void * >::LimitListLength | ( | int | limit | ) | [inherited] |
Cut off vector after at most length
elements.
bool SgVector< void * >::MaxLength | ( | int | length | ) | const [inherited] |
Test whether a vector is shorter than or equal to a given length.
Definition at line 161 of file SgVector.h.
References SgVector< T >::Length().
Merges two sorted vectors into this.
Equivalent to, but faster than:
for (SgVectorIterator<T> it(vector); it; ++it) Insert(*it);
bool SgVector< void * >::MinLength | ( | int | length | ) | const [inherited] |
Test whether a vector is as long as or longer than a given length.
Definition at line 174 of file SgVector.h.
References SgVector< T >::Length().
bool SgVector< void * >::NonEmpty | ( | ) | const [inherited] |
Return whether this vector contains more than zero elements.
Definition at line 180 of file SgVector.h.
References SgVector< T >::IsEmpty().
Compare whether the contents of two vectors are not identical.
Definition at line 51 of file SgVector.h.
Compare whether the contents of two vectors are identical.
Same length, and the same elements in the same sequence.
Definition at line 45 of file SgVector.h.
References SgVector< T >::m_vec.
T* SgVectorOf< T >::operator[] | ( | int | index | ) | const |
Return const reference to element.
index | Position of element in range 0..length-1 . |
Reimplemented from SgVector< void * >.
Definition at line 349 of file SgVector.h.
Referenced by SgVectorOf< std::string >::operator[]().
void * & SgVector< void * >::operator[] | ( | int | index | ) | [inherited] |
Return reference to element.
index | Position of element in range 0..length-1 . |
Definition at line 27 of file SgVector.h.
References SgVector< T >::m_vec.
void SgVector< void * >::PopBack | ( | ) | [inherited] |
Remove the last element of the vector.
The vector must not be empty.
T* SgVectorOf< T >::PopFront | ( | ) |
Remove element[0] of the vector.
The vector must not be empty.
Reimplemented from SgVector< void * >.
Definition at line 406 of file SgVector.h.
Referenced by SgVectorOf< std::string >::PopFront().
void SgVector< void * >::PushBack | ( | const void * & | elt | ) | [inherited] |
Add a single element at the end of the vector.
Definition at line 202 of file SgVector.h.
References SgVector< T >::Length(), SgVector< T >::m_vec, and SG_ASSERT.
void SgVectorOf< T >::PushBack | ( | const T * | element | ) |
Definition at line 400 of file SgVector.h.
Referenced by SgPropTextList::AddStringAtPoint(), SgVectorOf< std::string >::Include(), SgNode::PathToRoot(), SgVectorOf< std::string >::PushBack(), SgGameReader::ReadGames(), SgPropList::Remove(), SgPropTextList::SgPropTextList(), and SgNode::ShortestPathTo().
Push all elements from vector
to the back of this.
void SgVector< void * >::PushFront | ( | const void * & | elt | ) | [inherited] |
Insert element at the beginning of the vector.
void SgVectorOf< T >::PushFront | ( | const T * | element | ) |
Definition at line 394 of file SgVector.h.
Referenced by SgPropList::MoveToFront(), and SgVectorOf< std::string >::PushFront().
bool SgVector< void * >::RemoveDuplicates | ( | ) | [inherited] |
Removes all but the first copy of each element from the vector.
After calling RemoveDuplicates()
, UniqueElements()
is true
.
void SgVector< void * >::Reverse | ( | ) | [inherited] |
Definition at line 217 of file SgVector.h.
References SgVector< T >::m_vec.
Referenced by SgNode::ShortestPathTo().
Do vectors contain the same elements, possibly in different order?
void SgVector< void * >::SetTo | ( | const void * & | elt | ) | [inherited] |
Clear this vector and set it to contain only elt
.
Definition at line 223 of file SgVector.h.
References SgVector< T >::Clear(), and SgVector< T >::PushBack().
void SgVector< void * >::SetTo | ( | const void * * | array, | |
int | count | |||
) | [inherited] |
Clear this vector and set it to contain the count
elements from array[0]
to array[count - 1]
.
If count
is zero, the vector is just cleared.
void SgVector< void * >::Sort | ( | ) | [inherited] |
void SgVector< void * >::SortedRemoveDuplicates | ( | ) | [inherited] |
remove duplicates in a sorted vector
Swap the entire contents of this vector with *vector
.
Definition at line 244 of file SgVector.h.
References SgVector< T >::m_vec.
const void * & SgVector< void * >::TopNth | ( | int | index | ) | const [inherited] |
Returns the Nth-last element of the vector.
It must exist.
Definition at line 250 of file SgVector.h.
References SgVector< T >::m_vec, SgVector< T >::NonEmpty(), and SG_ASSERT.
Include all elements from set
into this vector.
Appends new elements at the end of this vector.
bool SgVector< void * >::UniqueElements | ( | ) | const [inherited] |
Check for duplicate elements.
true
if there are no duplicate elements in the vector. Useful for debugging. std::vector<void * >& SgVector< void * >::Vector | ( | ) | [inherited] |
Definition at line 269 of file SgVector.h.
References SgVector< T >::m_vec.
const std::vector<void * >& SgVector< void * >::Vector | ( | ) | const [inherited] |
Definition at line 274 of file SgVector.h.
References SgVector< T >::m_vec.