A simple bidirectional mapping between names (strings) and distinct consecutive non-negative indices.
More...
#include <IndexDirectory.h>
|
| IndexDirectory () |
| Create an empty directory object.
|
|
| IndexDirectory (const std::vector< std::string > &names) |
| Create a directory object initialized to a list of names. More...
|
|
int | getIndex (const std::string &name) const |
| Given a name, return the corresponding index (or -1). More...
|
|
std::string | getName (int index) const |
| Given an index, return the corresponding name (or ""). More...
|
|
const std::vector< std::string > & | getAllNames () const |
| Get a list of all the names available from the index directory. More...
|
|
bool | hasEntry (const std::string &name) const |
| Check whether the specified name exists in the directory. More...
|
|
size_t | size () const |
| Check the number of existing entries in the directory. More...
|
|
int | getNumEntries () const |
| Check the number of existing entries in the directory. More...
|
|
|
template<typename T > |
class | NamedDataBuilder |
|
class | DataGroupBuilder |
|
A simple bidirectional mapping between names (strings) and distinct consecutive non-negative indices.
Access to this class is thread-safe if all of the threads are only performing const operations, i.e. reading the names and indices.
§ IndexDirectory() [1/2]
SurgSim::DataStructures::IndexDirectory::IndexDirectory |
( |
const std::vector< std::string > & |
names | ) |
|
|
explicit |
Create a directory object initialized to a list of names.
- Parameters
-
§ IndexDirectory() [2/2]
SurgSim::DataStructures::IndexDirectory::IndexDirectory |
( |
const IndexDirectory & |
directory | ) |
|
|
protected |
§ addEntry()
int SurgSim::DataStructures::IndexDirectory::addEntry |
( |
const std::string & |
name | ) |
|
|
protected |
Create a new entry for the specified name.
Not generally accessible by external code, but is used by friend classes.
- See also
- NamedDataBuilder, DataGroupBuilder
- Parameters
-
name | The name, which should be non-empty and should not already exist in the directory. |
- Returns
- the index of the created entry, or -1 if the entry could not be added.
§ getAllNames()
const std::vector< std::string > & SurgSim::DataStructures::IndexDirectory::getAllNames |
( |
| ) |
const |
Get a list of all the names available from the index directory.
- Returns
- all the names, in index order.
§ getIndex()
int SurgSim::DataStructures::IndexDirectory::getIndex |
( |
const std::string & |
name | ) |
const |
|
inline |
Given a name, return the corresponding index (or -1).
- Parameters
-
- Returns
- the index for that name if one exists; -1 otherwise.
§ getName()
std::string SurgSim::DataStructures::IndexDirectory::getName |
( |
int |
index | ) |
const |
|
inline |
Given an index, return the corresponding name (or "").
- Parameters
-
- Returns
- the name for that index if one exists; an empty string otherwise.
§ getNumEntries()
int SurgSim::DataStructures::IndexDirectory::getNumEntries |
( |
| ) |
const |
|
inline |
Check the number of existing entries in the directory.
- Returns
- the size of the directory.
- See also
- size()
§ hasEntry()
bool SurgSim::DataStructures::IndexDirectory::hasEntry |
( |
const std::string & |
name | ) |
const |
|
inline |
Check whether the specified name exists in the directory.
- Parameters
-
- Returns
- true if the entry exists.
§ operator=()
§ size()
size_t SurgSim::DataStructures::IndexDirectory::size |
( |
| ) |
const |
|
inline |
Check the number of existing entries in the directory.
- Returns
- the size of the directory.
- See also
- getNumEntries()
The documentation for this class was generated from the following files:
- SurgSim/DataStructures/IndexDirectory.h
- SurgSim/DataStructures/IndexDirectory.cpp