Photon C++ Client API  5.0.7.3
Public Member Functions | List of all members
SequenceContainer< T, Etype > Class Template Referenceabstract
Inheritance diagram for SequenceContainer< T, Etype >:
Inheritance graph
[legend]
Collaboration diagram for SequenceContainer< T, Etype >:
Collaboration graph
[legend]

Public Member Functions

virtual ~SequenceContainer (void)=0
 
SequenceContainer< T, Etype > & operator= (const SequenceContainer< T, Etype > &toCopy)
 
template<template< typename > class FT>
SequenceContainer< T, Etype > & operator= (const SequenceContainer< FT, Etype > &toCopy)
 
bool operator== (const SequenceContainer< T, Etype > &toCompare) const
 
bool operator!= (const SequenceContainer< T, Etype > &toCompare) const
 
const Etype & operator[] (unsigned int index) const
 
const Etype & operator[] (int index) const
 
Etype & operator[] (unsigned int index)
 
Etype & operator[] (int index)
 
unsigned int getCapacity (void) const
 
bool contains (const Etype &elem) const
 
const Etype & getFirstElement (void) const
 
int getIndexOf (const Etype &elem) const
 
bool getIsEmpty (void) const
 
const Etype & getLastElement (void) const
 
int getLastIndexOf (const Etype &elem) const
 
unsigned int getSize (void) const
 
const Etype * getCArray (void) const
 
void copyInto (Etype *array) const
 
void addElement (const Etype &obj)
 
void addElements (const Etype *carray, unsigned int elementCount)
 
template<template< typename > class FT>
void addElements (const SequenceContainer< FT, Etype > &container)
 
void ensureCapacity (unsigned int minCapacity)
 
void removeAllElements (void)
 
bool removeElement (const Etype &obj)
 
void trimToSize (void)
 
const Etype & getElementAt (unsigned int index) const
 
void insertElementAt (const Etype &obj, unsigned int index)
 
void removeElementAt (unsigned int index)
 
void setElementAt (const Etype &obj, unsigned int index)
 
virtual JStringtoString (JString &retStr, bool withTypes=false) const
 
virtual JStringtoString (JString &retStr, bool withTypes=false) const=0
 
JString toString (bool withTypes=false) const
 
- Public Member Functions inherited from Base
virtual ~Base (void)=0
 
- Public Member Functions inherited from LoggingBase< Base >
virtual ~LoggingBase (void)=0
 
- Public Member Functions inherited from ToString
virtual ~ToString (void)
 
virtual JString typeToString (void) const
 
JString toString (bool withTypes=false) const
 

Additional Inherited Members

- Static Public Member Functions inherited from LoggingBase< Base >
static void setListener (const BaseListener *pBaseListener)
 
static int getDebugOutputLevel (void)
 
static bool setDebugOutputLevel (int debugLevel)
 
static const LogFormatOptionsgetLogFormatOptions (void)
 
static void setLogFormatOptions (const LogFormatOptions &options)
 

Constructor & Destructor Documentation

◆ ~SequenceContainer()

~SequenceContainer ( void  )
pure virtual

Destructor.

Member Function Documentation

◆ operator=() [1/2]

SequenceContainer< T, Etype > & operator= ( const SequenceContainer< T, Etype > &  toCopy)

operator=.

Makes a deep copy of its right operand into its left operand.

This overwrites old data in the left operand.

◆ operator=() [2/2]

SequenceContainer< T, Etype > & operator= ( const SequenceContainer< FT, Etype > &  toCopy)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator==()

bool operator== ( const SequenceContainer< T, Etype > &  toCompare) const

operator==.

Returns
true, if both operands are equal, false otherwise. Two instances are treated as equal, if they both contain the the same amount of elements and every element of one instance equals the other instance's element at the same index. If the element type is a pointer type, then the pointers are checked for equality, not the values, to which they point to.

◆ operator!=()

bool operator!= ( const SequenceContainer< T, Etype > &  toCompare) const

operator!=.

Returns
false, if operator==() would return true, true otherwise.

◆ operator[]() [1/4]

const Etype & operator[] ( unsigned int  index) const

operator[]. Wraps the function getElementAt(), so that you have the same syntax like for c-arrays.

◆ operator[]() [2/4]

const Etype & operator[] ( int  index) const

operator[]. Wraps the function getElementAt(), so that you have the same syntax like for c-arrays.

◆ operator[]() [3/4]

Etype & operator[] ( unsigned int  index)

operator[]. Enables c-array like write access to elements.

◆ operator[]() [4/4]

Etype & operator[] ( int  index)

operator[]. Enables c-array like write access to elements.

◆ getCapacity()

unsigned int getCapacity ( void  ) const

Returns the current capacity of the instance .

Returns
the current capacity.

◆ contains()

bool contains ( const Etype &  elem) const

Checks, if the instance contains the passed data as an element.

Parameters
elema reference to the data, you want to check. Needs to be either a primitive type or an object of a class with an overloaded == operator.
Returns
true, if the element was found, false otherwise.

◆ getFirstElement()

const Etype & getFirstElement ( void  ) const

Returns the first element of the instance. Shows undefined behavior for empty vectors.

Returns
the first element.

◆ getIndexOf()

int getIndexOf ( const Etype &  elem) const

Searches the instance from the first element in forward direction for the passed element and returns the first index, where it was found.

Parameters
elemthe element, to search for.
Returns
the index of the first found of the passed element or -1, if the element could not be found at all.

◆ getIsEmpty()

bool getIsEmpty ( void  ) const

Checks, if the instance is empty.

Returns
true, if the instance is empty, or false, if it contains at least one element.

◆ getLastElement()

const Etype & getLastElement ( void  ) const

Returns the last element of the instance. Shows undefined behavior for empty vectors.

Returns
the last element.

◆ getLastIndexOf()

int getLastIndexOf ( const Etype &  elem) const

Searches the instance from the last element in backward direction for the passed element and returns the first index, where it was found.

Parameters
elemthe element, to search for.
Returns
the index of the first found of the passed element or -1, if the element could not be found at all.

◆ getSize()

unsigned int getSize ( void  ) const

Returns the number of elements of the instance.

Returns
the size.

◆ getCArray()

const Etype * getCArray ( void  ) const
Remarks
For a deep-copy copyInto() should be used. Use getSize() to find out the element count of the returned array.
Returns
a read-only pointer copy of the Etype*, that is internally used to store the elements.

◆ copyInto()

void copyInto ( Etype *  array) const

Copies all elements of the container instance into the passed array. The caller has to make sure, that the array is big enough to take all elements of the vector, otherwise calling this function produces a buffer overflow.

Parameters
arrayan array of variables of the type of the template instantiation.
Returns
nothing.

◆ addElement()

void addElement ( const Etype &  elem)

Adds an element to the instance. This automatically resizes the instances capacity to it's old size + the capacityIncrement, that you passed, when creating the vector (if you passed no value for capacityIncrement, then it was set to it's default value (see constructor doc)), if the size of the instance has already reached it's capacity. When resizing occurs, then most likely the whole vector has to be copied to new memory. So this can be an expensive operation for huge vectors.

Note
When this function needs to increase the capacity, then all references/pointers to elements, that have been acquired before this function has been called, become invalid!
Parameters
elemthe element to add.
Returns
nothing.

◆ addElements() [1/2]

void addElements ( const Etype *  carray,
unsigned int  elementCount 
)

Adds the first 'elementCount' elements of the provided array to the instance. This automatically resizes the instances capacity to it's old size + 'elementCount', if the new size of the instance is bigger than it's old capacity. When resizing occurs, then most likely the whole vector has to be copied to new memory. So this can be an expensive operation for huge vectors.

Note
When this function needs to increase the capacity, then all references/pointers to elements, that have been acquired before this function has been called, become invalid!
Parameters
carraythe elements to add.
elementCountthe number of elements to add - must not be greater than the size of carray.
Returns
nothing.

◆ addElements() [2/2]

void addElements ( const SequenceContainer< FT, Etype > &  container)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Calls the above function with container.getCArray() and container.getSize() as parameters

Parameters
containerthe container class instance from which to copy the elements

◆ ensureCapacity()

void ensureCapacity ( unsigned int  minCapacity)

Resizes the instance to the passed capacity, if it's old capacity has been smaller. If resizing is needed, then the whole instance has to be copied into new memory, so in that case this is an expensive operation for huge instances. Call this function, before you add a lot of elements to the vector, to avoid multiple expensive resizes through adding.

Note
When this function needs to increase the capacity, then all references/pointers to elements, that have been acquired before this function has been called, will get invalid!
Parameters
minCapacitythe new capacity for the instance.
Returns
nothing.

◆ removeAllElements()

void removeAllElements ( void  )

Clears the instance.

Returns
nothing.

◆ removeElement()

bool removeElement ( const Etype &  obj)

Removes the first occurrence of the passed value from the instance.

Parameters
objthe element, to remove.
Returns
true, if an occurrence of the value has been removed, false, if the value could not be found.

◆ trimToSize()

void trimToSize ( void  )

Trims the capacity of the instance to the size, it currently uses. Call this function for a instance with huge unused capacity, if you do not want to add further elements to it and if you are short on memory. This function copies the whole vector to new memory, so it is expensive for huge vectors. If you only add one element to the instance later, it's copied again.

Note
Trimming a instance instance (that isn't already optimally trimmed) will make all references/pointers to elements, that have been acquired before this function has been called, invalid!

◆ getElementAt()

const Etype & getElementAt ( unsigned int  index) const

Returns the element of the instance at the passed index. This does not check for valid indexes and shows undefined behavior for invalid indexes!

Parameters
indexthe index of the element, that should be returned. Must not be bigger than the current size of the vector!
Returns
the element at the passed index.

◆ insertElementAt()

void insertElementAt ( const Etype &  obj,
unsigned int  index 
)

Inserts parameter one into the instance at the index, passed as parameter two. Because all elements above or at the passed index have to be moved one position up, it is expensive, to insert an element at an low index into a huge instance.

Parameters
objthe element, to insert.
indexthe position in the instance, the element is inserted at.
Returns
nothing.

◆ removeElementAt()

void removeElementAt ( unsigned int  index)

Removes the element at the passed index from the instance. Shows undefined behavior for invalid indexes.

Parameters
indexthe index of the element to remove.
Returns
nothing.

◆ setElementAt()

void setElementAt ( const Etype &  obj,
unsigned int  index 
)

Sets the element at the passed index of the instance to the passed new value. Shows undefined behavior for invalid indexes.

Parameters
objthe new value.
indexthe index of the element, which is set to the new value.
Returns
nothing.

◆ toString() [1/3]

JString & toString ( JString retStr,
bool  withTypes = false 
) const
virtual
Remarks
The cost of this function depends a lot on implementation details of the implementing subclasses, but for container classes this function can become quite expensive, if the instance contains huge amounts of data, as its cost for many container class implementations increases disproportionately high to the size of the payload.
Parameters
retStrreference to a string, to store the return-value in; the information, which is generated by this function, will be attached at the end of any eventually existing previous content of the string
withTypesset to true, to include type information in the generated string
Returns
a JString representation of the instance and its contents for debugging purposes.

Implements ToString.

◆ toString() [2/3]

toString
Remarks
The cost of this function depends a lot on implementation details of the implementing subclasses, but for container classes this function can become quite expensive, if the instance contains huge amounts of data, as its cost for many container class implementations increases disproportionately high to the size of the payload.
Parameters
retStrreference to a string, to store the return-value in; the information, which is generated by this function, will be attached at the end of any eventually existing previous content of the string
withTypesset to true, to include type information in the generated string
Returns
a JString representation of the instance and its contents for debugging purposes.

◆ toString() [3/3]

JString toString

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
withTypesset to true, to include type information in the generated string
Returns
a JString representation of the instance and its contents for debugging purposes.
See also
JString