stlab.adobe.com Adobe Systems Incorporated

static_table< KeyType, ValueType, Size, Traits > Class Template Reference
[Other containers: circular_queue, table_index, static_table, etc.]

A simple lookup table of fixed size. [under review]. More...

#include <static_table.hpp>

List of all members.

Public Types

typedef traits_type::entry_type entry_type
typedef traits_type::key_type key_type
typedef Traits traits_type
typedef traits_type::value_type value_type

Public Member Functions

const value_typeoperator() (const key_type &key) const
bool operator() (const key_type &key, value_type &result) const
void sort ()

Public Attributes

entry_type table_m [Size]

Detailed Description

template<typename KeyType, typename ValueType, std::size_t Size, typename Traits = static_table_traits<KeyType, ValueType>>
class adobe::static_table< KeyType, ValueType, Size, Traits >

static_table is intended to encapsulate the code used to initialize, sort, and perform lookups on lookup tables of static size. They are intended to be initialized without runtime code, though they must be sorted at runtime before any lookups can occur. Performing a lookup before the table is sorted will have undefined results.

Example:
    typdef adobe::static_table<adobe::name_t, boost::function<void (int)>, 4> table_t;

    static table_t some_table_s =
    {{
        table_t::entry_type(adobe::static_name_t("foo"),    &do_foo),
        table_t::entry_type(adobe::static_name_t("bar"),    &do_bar),
        table_t::entry_type(adobe::static_name_t("baz"),    &do_baz),
        table_t::entry_type(adobe::static_name_t("snafu"),  &do_snafu)
    }};

    some_table_s.sort();

    some_table_s(adobe::static_name_t("baz"))(42); // calls do_baz

Definition at line 221 of file static_table.hpp.


Member Typedef Documentation

A pair comprised of a key_type and a value_type.

Definition at line 226 of file static_table.hpp.

The type used for lookups in the table.

Definition at line 224 of file static_table.hpp.

The static_table_traits used to extend this static_table's functionality.

Definition at line 223 of file static_table.hpp.

The resultant type from a table lookup.

Definition at line 225 of file static_table.hpp.


Member Function Documentation

const adobe::static_table::value_type & operator() ( const key_type key ) const
Parameters:
keyThe key whose stored value we are searching for.
Exceptions:
std::logic_errorThrown if the key does not exist in the table.
Returns:
a reference to the value found associated with key.
Note:
Calling this function before calling sort() yields undefined results.

Definition at line 228 of file static_table.hpp.

bool operator() ( const key_type key,
value_type result 
) const
Parameters:
keyThe key whose stored value we are searching for.
resultSet to the value associated with the key if key is found.
Exceptions:
NoneGuaranteed not to throw.
Returns:
true if key was found and result's assignment did not throw. false otherwise.
Note:
Calling this function before calling sort() yields undefined results.

Definition at line 238 of file static_table.hpp.

void sort (  )

Sorts the contents of the table according to the static_table_traits type.

Definition at line 250 of file static_table.hpp.


Member Data Documentation

The static lookup table contents. This variable is not intended to be manipulated directly. It is publicly available to support static table initialization by the C++ compiler.

Definition at line 256 of file static_table.hpp.

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google