Versions Compared

Key

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

template<typename TKey, typename TValue, typename TKeyCompareFunctor, typename TValueCompareFunctor, typename TKeyPrepareCompareFunctor>
class Geo::GeoFixedBinarySearchMap

An associative container with performance OlogN and only one allocation.

This class may be used as a replacement for std::map when:

  • You know how many entries it will have.

  • You can add all the entries before lookup.

  • You care about the number of allocations, or memory fragmentation, or something. The sequence of operations is to create a map large enough to hold all entries, then use Key() and Value() to set the Key/Value pairs for each entry, then call Prepare(). Now that the map is ready, you call Lookup() to find the Value for a Key using a binary search. Duplicate key entries (as defined by the TKeyPrepareCompareFunctor) will be removed, leaving only the lowest value (as defined by the TKeyCompareFunctor).

Functions

NameDescription
~GeoFixedBinarySearchMap()

Destructor.

GeoFixedBinarySearchMap(s32)

Construct a BinarySearchMap.

Key(s32)

Obtain access to the key at the given index.

Lookup(const TKey &)

Return the index of the object in the map, or -1 if it isn't found.

NonCopyable(NonCopyable &&)

Defaulted to allow move.

operator[](s32)

Obtain the data at the given index, so that it can be read or modified.

operator=(NonCopyable &&)

Defaulted to allow move.

Prepare()

Prepare the structure for searching.

Size()

Returns the number of entries in the map.

Value(s32)

Obtain access to the value at the given index.


Anchor
a2317d938a82f9d78bdfea904eea8e0b2
a2317d938a82f9d78bdfea904eea8e0b2

Geo::GeoFixedBinarySearchMap< TKey, TValue, TKeyCompareFunctor, TValueCompareFunctor, TKeyPrepareCompareFunctor >::~GeoFixedBinarySearchMap

...

public: ~GeoFixedBinarySearchMap()

...

Destructor.


Anchor
af645c054f78c7282920a446f9b4cf8ee
af645c054f78c7282920a446f9b4cf8ee

Geo::GeoFixedBinarySearchMap< TKey, TValue, TKeyCompareFunctor, TValueCompareFunctor, TKeyPrepareCompareFunctor >::GeoFixedBinarySearchMap

...

public: GeoFixedBinarySearchMap
(
    s32 size
)

...

Construct a BinarySearchMap.

Parameters
[in]size

The number of entries that we want to put in the map.


Anchor
a97c7865ea9c44047b424d9827e0a33cf
a97c7865ea9c44047b424d9827e0a33cf

TKey& Geo::GeoFixedBinarySearchMap< TKey, TValue, TKeyCompareFunctor, TValueCompareFunctor, TKeyPrepareCompareFunctor >::Key

...

public: TKey & Key
(
    s32 idx
)

...

Obtain access to the key at the given index.


Anchor
a23548d1797129ecd05af83cce2239a93
a23548d1797129ecd05af83cce2239a93

s32 Geo::GeoFixedBinarySearchMap< TKey, TValue, TKeyCompareFunctor, TValueCompareFunctor, TKeyPrepareCompareFunctor >::Lookup

...

public: s32 Lookup
(
    const TKey & LookupThis
) const

...

Return the index of the object in the map, or -1 if it isn't found.


Anchor
adaed81b4c59f263dcb4e78c4126f4683
adaed81b4c59f263dcb4e78c4126f4683

Geo::NonCopyable::NonCopyable

...

public: NonCopyable
(
    NonCopyable &&
)

...

Defaulted to allow move.


Anchor
a68d8dd755baf7b681f2bacfa1669b75f
a68d8dd755baf7b681f2bacfa1669b75f

const GeoFixedBinarySearchMapData* Geo::GeoFixedBinarySearchMap< TKey, TValue, TKeyCompareFunctor, TValueCompareFunctor, TKeyPrepareCompareFunctor >::operator[]

...

public: const GeoFixedBinarySearchMapData * operator[]
(
    s32 idx
) const

...

Obtain the data at the given index, so that it can be read or modified.

Parameters
[in]idx

The position.

Returns

A pointer to the data at that position.


Anchor
a6abc781e23b8f4864e0b868806e0acbf
a6abc781e23b8f4864e0b868806e0acbf

NonCopyable& Geo::NonCopyable::operator=

...

public: NonCopyable & operator=
(
    NonCopyable &&
)

...

Defaulted to allow move.


Anchor
ab80fbcc2199cbf8e6770ac7595131c91
ab80fbcc2199cbf8e6770ac7595131c91

void Geo::GeoFixedBinarySearchMap< TKey, TValue, TKeyCompareFunctor, TValueCompareFunctor, TKeyPrepareCompareFunctor >::Prepare

...

public: void Prepare()

...

Prepare the structure for searching.

First sort it by Key and Data, and then remove duplicate keys.


Anchor
a1d5229e0abb1ab4af89a580509c059d5
a1d5229e0abb1ab4af89a580509c059d5

s32 Geo::GeoFixedBinarySearchMap< TKey, TValue, TKeyCompareFunctor, TValueCompareFunctor, TKeyPrepareCompareFunctor >::Size

...

public: s32 Size()

...

Returns the number of entries in the map.


Anchor
a90e61b816271b9846c0db9ba36d9bd0c
a90e61b816271b9846c0db9ba36d9bd0c

TValue& Geo::GeoFixedBinarySearchMap< TKey, TValue, TKeyCompareFunctor, TValueCompareFunctor, TKeyPrepareCompareFunctor >::Value

...

public: TValue & Value
(
    s32 idx
) const

...

Obtain access to the value at the given index.