Marine Library
1.0
C++ library for Linux Networking Development
|
A hash table for fd (file descriptor) related data. More...
#include <fd_data_map.hh>
Public Types | |
typedef Container | container_type |
typedef T | value_type |
typedef T & | reference |
typedef const T & | const_reference |
Public Member Functions | |
CFdMap (size_t capacity=100) | |
Initialize this object. More... | |
size_t | capacity () const |
Get current capacity. More... | |
void | capacity (size_t sz) |
Set current capacity. More... | |
reference | operator[] (int fd) |
Get value for an fd. More... | |
const_reference | operator[] (int fd) const |
Get value for an fd. More... | |
void | clear () |
Clear all key/value pairs. | |
A hash table for fd (file descriptor) related data.
Key MUST be file descriptors, which are non-negative and of type int
. In fact the file descriptor acts as an index to an underlying container of values. Because the number of files a process can open is limited, e.g. 1024 (it is modifiable), there's no chance for the underlying container to grow unexpectedly. So do NOT use CFdMap as a generic int
to value hash table.
The underlying container is vector
by default, but you can specify it as you like.
T | Value type |
Container | Container type, default to std::vector<T> |
|
inlineexplicit |
Initialize this object.
capacity
is used as a hint to the number of key/value pairs this object wants to hold. But CFdMap is free to expand as needed.
capacity | Initial reserved room for key/value pairs |
|
inline |
Get current capacity.
|
inline |
Set current capacity.
sz | New capacity |
|
inline |
Get value for an fd.
fd | A file descriptor |
fd
|
inline |
Get value for an fd.
fd | A file descriptor |
fd