Zero  0.1.0
Classes | Public Member Functions | Private Attributes | List of all members
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index > Class Template Reference

Multiple Clocks with a Common Set of Entries. More...

#include <multi_clock.hpp>

Classes

class  IndexPair
 Pair of keys. More...
 

Public Member Functions

 MultiHandedClock (key_type entryCount)
 Constructor of Multiple Clocks with a Common Set of Entries. More...
 
 ~MultiHandedClock ()
 Destructor of Multiple Clocks with a Common Set of Entries. More...
 
template<ClockIndex clock>
void getHead (value_type &head) const
 Get the value of the entry where the clock hand of the specified clock points to. More...
 
template<ClockIndex clock>
void setHead (const value_type newValue)
 Set the value of the entry where the clock hand of the specified clock points to. More...
 
template<ClockIndex clock>
void getHeadIndex (key_type &headIndex) const
 Get the index of the entry where the clock hand of the specified clock points to. More...
 
template<ClockIndex clock>
void moveHead ()
 Move the clock hand forward. More...
 
template<ClockIndex clock>
void addTail (const key_type &index)
 Make the specified index the__ZERO_MULTICLOCK_HPP tail of the specified clock. More...
 
template<ClockIndex clock>
void addTail (key_type &&index)
 Make the specified index the tail of the specified clock (with move semantics) More...
 
void addBefore (const key_type &inside, const key_type &newEntry)
 Add the specified index before another index in an arbitrary clock. More...
 
void addBefore (const key_type &inside, key_type &&newEntry)
 Add the specified index before another index in an arbitrary clock (with move semantics) More...
 
void addAfter (const key_type &inside, const key_type &newEntry)
 Add the specified index after another index in an arbitrary clock. More...
 
void addAfter (const key_type &inside, const key_type &&newEntry)
 Add the specified index after another index in an arbitrary clock (with move semantics) More...
 
template<ClockIndex clock>
void removeHead (key_type &removedIndex)
 Remove the head entry from the specified clock. More...
 
void remove (const key_type &index)
 Remove the specified entry from any clock. More...
 
template<ClockIndex source, ClockIndex destination>
void switchHeadToTail (key_type &movedIndex)
 Moves an entry from the head of one clock to the tail of another one. More...
 
template<ClockIndex clock>
key_type sizeOf () const noexcept
 Returns the number of entries in the specified clock. More...
 
template<ClockIndex clock>
bool isEmpty () const noexcept
 Returns true if the specified clock is empty. More...
 
bool isValidIndex (const key_type &index) const noexcept
 Returns true if the specified index is valid. More...
 
bool isContainedIndex (const key_type &index) const noexcept
 Returns true if the specified index is contained in any clock. More...
 
value_type & get (const key_type &index) noexcept
 Returns a reference to the value that corresponds to the specified index. More...
 
const value_type & get (const key_type &index) const noexcept
 Returns a reference to the value that corresponds to the specified index. noexcept More...
 
void set (const key_type &index, const value_type &newValue) noexcept
 Sets the value that corresponds to the specified index. More...
 
void set (const key_type &index, value_type &&newValue) noexcept
 Sets the value that corresponds to the specified index (with move semantics) More...
 
value_type & operator[] (const key_type &index) noexcept
 Returns a reference to the value that corresponds to the specified index. More...
 
const value_type & operator[] (const key_type &index) const noexcept
 Returns a reference to the value that corresponds to the specified index. noexcept More...
 
ClockIndexgetClockIndex (const key_type &index) noexcept
 Returns a reference to the index of the clock where the specified index is contained in. More...
 
const ClockIndexgetClockIndex (const key_type &index) const noexcept
 Returns a reference to the index of the clock where the specified index is contained in. noexcept More...
 

Private Attributes

key_type _entryCount
 Number of entries the clocks can hold. More...
 
std::vector< value_type > _values
 Values. More...
 
std::vector< IndexPair_clocks
 Clocks. More...
 
std::vector< ClockIndex_clockMembership
 Membership of indexes to clocks. More...
 
std::array< key_type, clock_count > _hands
 Clock hands. More...
 
std::array< key_type, clock_count > _sizes
 Number of elements in the clocks. More...
 

Detailed Description

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
class zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >

Multiple Clocks with a Common Set of Entries.

Represents multiple clocks of key-value pairs using one common set of entries. The total size of the clocks (number of key-value pairs) is fixed but the sizes of the different clocks are variable and limiting those is not supported. The keys are stored implicitly as array indices for the values and therefore it works best when the domain of the keys is very limited. Each clock has an index (starting from 0) which is required when working with it. It is possible to add an entry at the tail of a clock and to remove one from its head. It is also possible to get the key or get/set the value of the entry where the clock hand of a clock points to. In addition to the typical interface of a single clock, it is possible to swap one entry from one clock's head to another clock's tail.

The computational complexity of the methods of this class is in \(\mathcal{O}\left(1\right)\) and the space complexity of this class is in \(\mathcal{O}\left(n\right)\) regarding the key range.

Template Parameters
key_typeThe data type of the key of the key-value pairs where each key is unique within one instance of this data structure.
value_typeThe data type of the value of the key-value pairs where each value instance corresponds to a key.
clock_countContains the total number of clocks contained in this MultiHandedClock and therefore it specifies the highest valid ClockIndex, the number of clock _hands etc. The actual number of clocks might be smaller as some clocks can be empty.
invalid_indexThis specifies an invalid key which can be used to mark that a clock is empty and therefore the clock hand points to this value. This should have the semantics of null for the specified key template parameter therefore a natural choice of this for the case that key is a pointer would be nullptr.
invalid_clock_indexThis specifies an invalid clock index which can be used to mark inside _clockMembership that an index does not belong to any clock. This should have the semantics of null for ClockIndex and is equal to clock_count (greatest clock index plus 1).
Author
Max Gilbert

Constructor & Destructor Documentation

§ MultiHandedClock()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::MultiHandedClock ( key_type  entryCount)
inline

Constructor of Multiple Clocks with a Common Set of Entries.

Constructs a new MultiHandedClock with a specified combined capacity of the clocks and a number of (initially empty) clocks specified in the template parameter clock_count . This constructor allocates the memory to store _entryCount entries.

Parameters
entryCountThe range of the clock indexes and the combined size of the clocks.

§ ~MultiHandedClock()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::~MultiHandedClock ( )
inline

Destructor of Multiple Clocks with a Common Set of Entries.

Destructs this instance of MultiHandedClock and deallocates the memory used to store the clocks.

Member Function Documentation

§ addAfter() [1/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::addAfter ( const key_type &  inside,
const key_type &  newEntry 
)
inline

Add the specified index after another index in an arbitrary clock.

Adds a new entry with the specified index newEntry in the clock after the entry inside. The entry that was after inside before will be IndexPair._after newEntry. Adding a new entry is only possible if the index is not already contained inside any clock of the same MultiHandedClock.

Parameters
insideThis index will be the entry before the new entry.
newEntryThis is the index of the new entry.
Exceptions
MultiHandedClockInvalidIndexExceptionIf the specified newEntry or inside is invalid.
MultiHandedClockAlreadyContainedExceptionIf the specified newEntry could not be added because it is already contained in some clock.
MultiHandedClockNotContainedExceptionIf the position for the insertion is not valid because the specified inside is not contained in any clock.

§ addAfter() [2/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::addAfter ( const key_type &  inside,
const key_type &&  newEntry 
)
inline

Add the specified index after another index in an arbitrary clock (with move semantics)

Adds a new entry with the specified index newEntry in the clock after the entry inside using move semantics. The entry that was after inside before will be IndexPair._after newEntry. Adding a new entry is only possible if the index is not already contained inside any clock of the same MultiHandedClock.

Parameters
insideThis index will be the entry before the new entry.
newEntryThis is the index of the new entry.
Exceptions
MultiHandedClockInvalidIndexExceptionIf the specified newEntry or inside is invalid.
MultiHandedClockAlreadyContainedExceptionIf the specified newEntry could not be added because it is already contained in some clock.
MultiHandedClockNotContainedExceptionIf the position for the insertion is not valid because the specified inside is not contained in any clock.

§ addBefore() [1/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::addBefore ( const key_type &  inside,
const key_type &  newEntry 
)
inline

Add the specified index before another index in an arbitrary clock.

Adds a new entry with the specified index newEntry in the clock before the entry inside. The entry that was before inside before will be IndexPair._before newEntry. Adding a new entry is only possible if the index is not already contained inside any clock of the same MultiHandedClock.

Parameters
insideThis index will be the entry after the new entry.
newEntryThis is the index of the new entry.
Exceptions
MultiHandedClockInvalidIndexExceptionIf the specified newEntry or inside is invalid.
MultiHandedClockAlreadyContainedExceptionIf the specified newEntry could not be added because it is already contained in some clock.
MultiHandedClockNotContainedExceptionIf the position for the insertion is not valid because the specified inside is not contained in any clock.

§ addBefore() [2/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::addBefore ( const key_type &  inside,
key_type &&  newEntry 
)
inline

Add the specified index before another index in an arbitrary clock (with move semantics)

Adds a new entry with the specified index newEntry in the clock before the entry inside using move semantics. The entry that was before inside before will be IndexPair._before newEntry. Adding a new entry is only possible if the index is not already contained inside any clock of the same MultiHandedClock.

Parameters
insideThis index will be the entry after the new entry.
newEntryThis is the index of the new entry.
Exceptions
MultiHandedClockInvalidIndexExceptionIf the specified newEntry or inside is invalid.
MultiHandedClockAlreadyContainedExceptionIf the specified newEntry could not be added because it is already contained in some clock.
MultiHandedClockNotContainedExceptionIf the position for the insertion is not valid because the specified inside is not contained in any clock.

§ addTail() [1/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
template<ClockIndex clock>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::addTail ( const key_type &  index)
inline

Make the specified index the__ZERO_MULTICLOCK_HPP tail of the specified clock.

Adds a new entry with the specified index to the tail of the specified clock. The new entry will be the tail of the clock and the previous tail entry will be IndexPair._before the new entry. Adding a new entry is only possible if the index is not already contained inside any clock of the same MultiHandedClock.

Template Parameters
clockThe clock where the new entry should be added to at the tail.
Parameters
indexThe index of the new entry.
Exceptions
MultiHandedClockInvalidIndexExceptionIf the specified index is invalid.
MultiHandedClockAlreadyContainedExceptionIf the specified index could not be added because it is already contained in some clock.

§ addTail() [2/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
template<ClockIndex clock>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::addTail ( key_type &&  index)
inline

Make the specified index the tail of the specified clock (with move semantics)

Adds a new entry with the specified index to the tail of the specified clock using move semantics. The new entry will be the tail of the clock and the previous tail entry will be IndexPair._before the new entry. Adding a new entry is only possible if the index is not already contained inside any clock of the same MultiHandedClock.

Template Parameters
clockThe clock where the new entry should be added to at the tail.
Parameters
indexThe index of the new entry.
Exceptions
MultiHandedClockInvalidIndexExceptionIf the specified index is invalid.
MultiHandedClockAlreadyContainedExceptionIf the specified index could not be added because it is already contained in some clock.

§ get() [1/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::get ( const key_type &  index)
inlinenoexcept

Returns a reference to the value that corresponds to the specified index.

Returns a reference to the value that corresponds to the specified index, independent of the membership of that index to any clock.

Parameters
indexThe index whose value gets returned.
Returns
A reference to the value corresponding the specified index if this index is valid inside this MultiHandedClock or a reference to the value of the template parameter invalid_index else.

§ get() [2/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
const value_type& zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::get ( const key_type &  index) const
inlinenoexcept

Returns a reference to the value that corresponds to the specified index. noexcept

Returns a reference to the value that corresponds to the specified index, independent of the membership of that index to any clock.

Parameters
indexThe index whose value gets returned.
Returns
A reference to the value corresponding the specified index if this index is valid inside this MultiHandedClock or a reference to the value of the template parameter invalid_index else. noexcept

§ getClockIndex() [1/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::getClockIndex ( const key_type &  index)
inlinenoexcept

Returns a reference to the index of the clock where the specified index is contained in.

Returns a reference to the index of the clock where the specified index is contained in or template parameter invalid_clock_index of the specified index is invalid or not contained in any clock.

Parameters
indexThe index whose clock index gets returned.
Returns
A reference to the index of the clock where the specified index is contained in or a reference to the value of the template parameter invalid_clock_index of the index is invalid in this MultiHandedClock or if it is not contained in any clock.

§ getClockIndex() [2/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
const ClockIndex& zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::getClockIndex ( const key_type &  index) const
inlinenoexcept

Returns a reference to the index of the clock where the specified index is contained in. noexcept

Returns a reference to the index of the clock where the specified index is contained in or template parameter invalid_clock_index of the specified index is invalid or not contained in any clock.

Parameters
indexThe index whose clock index gets returned.
Returns
A reference to the index of the clock where the specified index is contained in or a reference to the value of the template parameter invalid_clock_index of the index is invalid in this MultiHandedClock or if it is not contained in any clock. noexcept

§ getHead()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
template<ClockIndex clock>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::getHead ( value_type &  head) const
inline

Get the value of the entry where the clock hand of the specified clock points to.

Returns the value of the head of the specified clock.

Template Parameters
clockThe clock whose head's value should be returned.
Parameters
[out]headThe value of the head of the specified clock.
Exceptions
MultiHandedClockEmptyExceptionIf the specified clock is empty.

§ getHeadIndex()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
template<ClockIndex clock>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::getHeadIndex ( key_type &  headIndex) const
inline

Get the index of the entry where the clock hand of the specified clock points to.

Returns the index of the head of the specified clock.

Template Parameters
clockThe clock whose head should be returned.
Parameters
[out]headIndexThe index of the head of the specified clock.
Exceptions
MultiHandedClockEmptyExceptionIf the specified clock is empty.

§ isContainedIndex()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::isContainedIndex ( const key_type &  index) const
inlinenoexcept

Returns true if the specified index is contained in any clock.

Returns true if the specified index is valid in this MultiHandedClock and if it is contained in any clock within this MultiHandedClock.

Parameters
indexThe index whose clock membership is checked.
Returns
true if the specified index is contained in any clock.

§ isEmpty()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
template<ClockIndex clock>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::isEmpty ( ) const
inlinenoexcept

Returns true if the specified clock is empty.

Returns true if the specified clock currently contains entries.

Template Parameters
clockThe clock whose emptiness gets returned.
Returns
true if the specified clock contains entries, false else.

§ isValidIndex()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::isValidIndex ( const key_type &  index) const
inlinenoexcept

Returns true if the specified index is valid.

Returns true if the specified index is valid in this MultiHandedClock.

Parameters
indexThe index whose validity is checked.
Returns
true if the specified index is valid.

§ moveHead()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
template<ClockIndex clock>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::moveHead ( )
inline

Move the clock hand forward.

Moves the tail entry of the specified clock before the head of the same clock. Therefore the previous tail entry becomes the new head entry. The previous head will become the element IndexPair._before the new head and the new tail will be the element IndexPair._after the new head.

Template Parameters
clockThe clock whose clock hand should be moved.
Exceptions
MultiHandedClockEmptyExceptionIf the specified clock is empty.

§ operator[]() [1/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::operator[] ( const key_type &  index)
inlinenoexcept

Returns a reference to the value that corresponds to the specified index.

Returns a reference to the value that corresponds to the specified index, independent of the membership of that index to any clock.

Parameters
indexThe index whose value gets returned.
Returns
A reference to the value corresponding the specified index if this index is valid inside this MultiHandedClock or a reference to the value of the template parameter invalid_index , else.

§ operator[]() [2/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
const value_type& zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::operator[] ( const key_type &  index) const
inlinenoexcept

Returns a reference to the value that corresponds to the specified index. noexcept

Returns a reference to the value that corresponds to the specified index, independent of the membership of that index to any clock.

Parameters
indexThe index whose value gets returned.
Returns
A reference to the value corresponding the specified index if this index is valid inside this MultiHandedClock or a reference to the value of the template parameter invalid_index , else. noexcept

§ remove()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::remove ( const key_type &  index)
inline

Remove the specified entry from any clock.

Removed the specified entry from any clock. The entry before this entry will be before the entry after the specified entry and the entry after this entry will be after the entry before the specified entry.

Parameters
indexThe index of the entry that gets removed.
Exceptions
MultiHandedClockInvalidIndexExceptionIf the specified index is invalid (and therefore also not contained in any clock).
MultiHandedClockNotContainedExceptionIf the specified index could not be removed from some clock because it is not contained in one.

§ removeHead()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
template<ClockIndex clock>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::removeHead ( key_type &  removedKey)
inline

Remove the head entry from the specified clock.

Removes the entry at the head of the specified clock from that clock. The new head of the clock will be the entry after the removed entry and therefore the clock hand will point to that index.

Template Parameters
clockThe index of the clock whose head entry will be removed.
Parameters
[out]removedKeyThe index of the entry that was removed.
Exceptions
MultiHandedClockEmptyExceptionIf the specified clock is empty.

§ set() [1/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::set ( const key_type &  index,
const value_type &  newValue 
)
inlinenoexcept

Sets the value that corresponds to the specified index.

Sets the value that corresponds to the specified index, independent of the membership of that index to any clock.

Parameters
indexThe index whose value gets set.
newValueThe new value for the specified index if this index is valid inside this MultiHandedClock or for the template parameter invalid_index , else.

§ set() [2/2]

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::set ( const key_type &  index,
value_type &&  newValue 
)
inlinenoexcept

Sets the value that corresponds to the specified index (with move semantics)

Sets the value that corresponds to the specified index using move semantics, independent of the membership of that index to any clock.

Parameters
indexThe index whose value gets set.
newValueThe new value for the specified index if this index is valid inside this MultiHandedClock or for the template parameter invalid_index , else.

§ setHead()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
template<ClockIndex clock>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::setHead ( const value_type  newValue)
inline

Set the value of the entry where the clock hand of the specified clock points to.

Sets the value of the head of the specified clock to the specified value.

Template Parameters
clockThe clock whose head's value should be set.
Parameters
newValueThe new value of the head of the specified clock.
Exceptions
MultiHandedClockEmptyExceptionIf the specified clock is empty.

§ sizeOf()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
template<ClockIndex clock>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::sizeOf ( ) const
inlinenoexcept

Returns the number of entries in the specified clock.

Returns the number of entries that is currently contained in the specified clock.

Template Parameters
clockThe clock whose current size gets returned.
Returns
Number of entries in the specified clock .

§ switchHeadToTail()

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
template<ClockIndex source, ClockIndex destination>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::switchHeadToTail ( key_type &  movedIndex)
inline

Moves an entry from the head of one clock to the tail of another one.

Removes the index at the head of the source clock and adds it as tail of the destination clock.

Template Parameters
sourceThe index of the clock whose head gets moved. The head will be removed from this clock.
destinationThe index of the clock where the moved entry gets added to the tail.
Parameters
[out]movedIndexThe index of the entry that was moved from one clock to another.
Exceptions
MultiHandedClockEmptyExceptionIf the head of the specified source could not be taken because the clock is empty.

Member Data Documentation

§ _clockMembership

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::_clockMembership
private

Membership of indexes to clocks.

This array specifies for each index in the domain to which clock it belongs. If an index is not part of a clock, the template parameter invalid_clock_index is used.

§ _clocks

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::_clocks
private

Clocks.

Contains the doubly linked, circular lists representing the clocks (every not empty clock is contained in here). The IndexPair stored at index i contains the indexes within the same clock after i and before i .

§ _entryCount

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::_entryCount
private

Number of entries the clocks can hold.

Contains the number of key-value pairs that can be stored in the clocks combined. When this MultiHandedClock is initialized, it allocates memory to hold this many entries. This also specifies the highest key that is allowed in the clocks (_entryCount - 1 ).

§ _hands

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::_hands
private

Clock hands.

Contains the clock hands of the clocks. Therefore it contains the index of each clock's head. If a clock is empty, this contains the template parameter invalid_index .

§ _sizes

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::_sizes
private

Number of elements in the clocks.

Contains for each clock the number of elements this clock currently has.

§ _values

template<class key_type, class value_type, uint32_t clock_count, key_type invalid_index, key_type invalid_clock_index = clock_count>
zero::multi_clock::MultiHandedClock< key_type, value_type, clock_count, invalid_index, invalid_clock_index >::_values
private

Values.

Holds the values corresponding the keys. The corresponding key is the index of this array.


The documentation for this class was generated from the following file: