Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

template<typename, typename>
class Geo::GeoKeyValueArray

A fast implementation of a set associative container, this one using a sorted array of key values to lookup a similar array of value pointers.

  • Requires that the key type support both operator< and operator<=. This could be removed by a small refactor of the binary search loop.

  • Requires that the value type be stored on the heap, as this class only stores pointers. Fixing this would require changing the class to work with iterators (to allow a sentinel value such as end() to represent a missing value).

Functions

NameDescription
Clear()

Removes all entries from the collection. Remember, this object did not take ownership.

Find(const TKey &)

Find a value in the collection with TKey key.

FindIndex(const TKey &)

Find the index of a given key.

GetKey(s32)

Get the key at index i.

GetSize()

Returns the number of entries in the collection.

GetValue(s32)

Get the value at index i.

GetValue(s32)

Get the value at index i.

Insert(const TKey &, TValue *)

Insert an pointer to a TValue item into the container.

operator[](s32)

Get the value at index i.

operator[](s32)

Get the value at index i.

Remove(const TKey &, s32 &)

Remove the entry referenced to by key.

Remove(const TKey &)

Remove the entry referenced to by key.

RemoveIndex(s32)

Remove the entry referenced by index obtained by FindIndex (note that all indices are of course invalidated).


Anchor
a6547fe34cfb32ab9e48207059828e393
a6547fe34cfb32ab9e48207059828e393

void Geo::GeoKeyValueArray< TKey, TValue >::Clear

...

public: void Clear()

...

Removes all entries from the collection. Remember, this object did not take ownership.


Anchor
a4ba9ad2efeff9609f12e1f291fa092f5
a4ba9ad2efeff9609f12e1f291fa092f5

TValue * Geo::GeoKeyValueArray< TKey, TValue >::Find

...

public: TValue * Find
(
    const TKey & key
) const

...

Find a value in the collection with TKey key.

O(logN) operation.

Returns

NULL on failure.


Anchor
aef1899abdfdaa6e77a4159d6f38cf99e
aef1899abdfdaa6e77a4159d6f38cf99e

s32 Geo::GeoKeyValueArray< TKey, TValue >::FindIndex

...

public: s32 FindIndex
(
    const TKey & key
) const

...

Find the index of a given key.

O(logN) operation.

Returns

-1 on failure.


Anchor
ac9d72481e7eae365e4b2254819bc19d7
ac9d72481e7eae365e4b2254819bc19d7

TKey Geo::GeoKeyValueArray< TKey, TValue >::GetKey

...

public: TKey GetKey
(
    s32 i
) const

...

Get the key at index i.


Anchor
a8bfb98e945de3f47de58a1847d940d24
a8bfb98e945de3f47de58a1847d940d24

s32 Geo::GeoKeyValueArray< TKey, TValue >::GetSize

...

public: s32 GetSize() const

...

Returns the number of entries in the collection.


Anchor
a248a6aef8a70abb89410e290198bb4e0
a248a6aef8a70abb89410e290198bb4e0

const TValue* Geo::GeoKeyValueArray< TKey, TValue >::GetValue

...

public: const TValue * GetValue
(
    s32 i
) const

...

Get the value at index i.


Anchor
a61cf88d659d3ccc0f05fe17891058cd8
a61cf88d659d3ccc0f05fe17891058cd8

TValue*& Geo::GeoKeyValueArray< TKey, TValue >::GetValue

...

public: TValue *& GetValue
(
    s32 i
)

...

Get the value at index i.


Anchor
a7250d594ee22af23553182477651d343
a7250d594ee22af23553182477651d343

s32 Geo::GeoKeyValueArray< TKey, TValue >::Insert

...

public: s32 Insert
(
    const TKey & key,
    TValue * value
)

...

Insert an pointer to a TValue item into the container.

O(logN) operation.

Returns

-1 on failure.


Anchor
ab5dbc35669a123086e2c534aa5283f9f
ab5dbc35669a123086e2c534aa5283f9f

const TValue* Geo::GeoKeyValueArray< TKey, TValue >::operator[]

...

public: const TValue * operator[]
(
    s32 i
) const

...

Get the value at index i.


Anchor
a11d677905e5f1bdef46d688d8f7549d1
a11d677905e5f1bdef46d688d8f7549d1

TValue*& Geo::GeoKeyValueArray< TKey, TValue >::operator[]

...

public: TValue *& operator[]
(
    s32 i
)

...

Get the value at index i.


Anchor
afa2ebb657da517e8b2c7d7c9238eafd4
afa2ebb657da517e8b2c7d7c9238eafd4

TValue * Geo::GeoKeyValueArray< TKey, TValue >::Remove

...

public: TValue * Remove
(
    const TKey & key,
    s32 & removedIndex
)

...

Remove the entry referenced to by key.

removedIndex will be filled by previous index value (note that all indices are of course invalidated).

Returns

NULL if not found in collection, otherwise the value object.


Anchor
a25b2d60369cbd611d242143106662ff5
a25b2d60369cbd611d242143106662ff5

TValue* Geo::GeoKeyValueArray< TKey, TValue >::Remove

...

public: TValue * Remove
(
    const TKey & key
)

...

Remove the entry referenced to by key.

Returns

NULL if not found in collection, otherwise the value object.


Anchor
a3c40f16964205e826299cacaa9a28b57
a3c40f16964205e826299cacaa9a28b57

TValue * Geo::GeoKeyValueArray< TKey, TValue >::RemoveIndex

...

public: TValue * RemoveIndex
(
    s32 index
)

...

Remove the entry referenced by index obtained by FindIndex (note that all indices are of course invalidated).

Returns

NULL if not found in collection, otherwise the value object.