JsonCpp project page | JsonCpp home page |
A linked page based hash-table implementation used internally by Value. More...
#include <json/value.h>
Public Types | |
typedef unsigned int | HashKey |
typedef unsigned int | BucketIndex |
Public Member Functions | |
ValueInternalMap () | |
ValueInternalMap (const ValueInternalMap &other) | |
ValueInternalMap & | operator= (const ValueInternalMap &other) |
~ValueInternalMap () | |
void | swap (ValueInternalMap &other) |
BucketIndex | size () const |
void | clear () |
bool | reserveDelta (BucketIndex growth) |
bool | reserve (BucketIndex newItemCount) |
const Value * | find (const char *key) const |
Value * | find (const char *key) |
Value & | resolveReference (const char *key, bool isStatic) |
void | remove (const char *key) |
void | doActualRemove (ValueInternalLink *link, BucketIndex index, BucketIndex bucketIndex) |
ValueInternalLink *& | getLastLinkInBucket (BucketIndex bucketIndex) |
Value & | setNewItem (const char *key, bool isStatic, ValueInternalLink *link, BucketIndex index) |
Value & | unsafeAdd (const char *key, bool isStatic, HashKey hashedKey) |
HashKey | hash (const char *key) const |
int | compare (const ValueInternalMap &other) const |
Friends | |
class | ValueIteratorBase |
class | Value |
A linked page based hash-table implementation used internally by Value.
ValueInternalMap is a tradional bucket based hash-table, with a linked list in each bucket to handle collision. There is an addional twist in that each node of the collision linked list is a page containing a fixed amount of value. This provides a better compromise between memory usage and speed.
Each bucket is made up of a chained list of ValueInternalLink. The last link of a given bucket can be found in the 'previous_' field of the following bucket. The last link of the last bucket is stored in tailLink_ as it has no following bucket. Only the last link of a bucket may contains 'available' item. The last link always contains at least one element unless is it the bucket one very first link.
typedef unsigned int Json::ValueInternalMap::BucketIndex |
typedef unsigned int Json::ValueInternalMap::HashKey |
Json::ValueInternalMap::ValueInternalMap | ( | ) |
Definition at line 168 of file json_internalmap.inl.
Json::ValueInternalMap::ValueInternalMap | ( | const ValueInternalMap & | other | ) |
Definition at line 177 of file json_internalmap.inl.
References reserve(), and resolveReference().
Json::ValueInternalMap::~ValueInternalMap | ( | ) |
Definition at line 207 of file json_internalmap.inl.
References Json::mapAllocator(), Json::ValueInternalLink::next_, Json::ValueMapAllocator::releaseMapBuckets(), and Json::ValueMapAllocator::releaseMapLink().
void Json::ValueInternalMap::clear | ( | ) |
Definition at line 245 of file json_internalmap.inl.
References swap().
int Json::ValueInternalMap::compare | ( | const ValueInternalMap & | other | ) | const |
Definition at line 471 of file json_internalmap.inl.
References Json::Value::compare(), and find().
void Json::ValueInternalMap::doActualRemove | ( | ValueInternalLink * | link, |
BucketIndex | index, | ||
BucketIndex | bucketIndex | ||
) |
Definition at line 364 of file json_internalmap.inl.
References getLastLinkInBucket(), Json::ValueInternalLink::itemPerLink, Json::ValueInternalLink::items_, Json::mapAllocator(), Json::ValueInternalLink::next_, Json::ValueInternalLink::previous_, Json::ValueMapAllocator::releaseMapLink(), and Json::Value::swap().
Referenced by remove().
const Value * Json::ValueInternalMap::find | ( | const char * | key | ) | const |
Definition at line 279 of file json_internalmap.inl.
References hash(), Json::ValueInternalLink::itemPerLink, and Json::ValueInternalLink::next_.
Value * Json::ValueInternalMap::find | ( | const char * | key | ) |
Definition at line 302 of file json_internalmap.inl.
References find().
ValueInternalLink *& Json::ValueInternalMap::getLastLinkInBucket | ( | BucketIndex | bucketIndex | ) |
Definition at line 407 of file json_internalmap.inl.
References Json::ValueInternalLink::previous_.
Referenced by doActualRemove(), and unsafeAdd().
ValueInternalMap::HashKey Json::ValueInternalMap::hash | ( | const char * | key | ) | const |
Definition at line 461 of file json_internalmap.inl.
Referenced by find(), remove(), and resolveReference().
ValueInternalMap & Json::ValueInternalMap::operator= | ( | const ValueInternalMap & | other | ) |
Definition at line 199 of file json_internalmap.inl.
References swap().
void Json::ValueInternalMap::remove | ( | const char * | key | ) |
Definition at line 339 of file json_internalmap.inl.
References doActualRemove(), hash(), Json::ValueInternalLink::itemPerLink, and Json::ValueInternalLink::next_.
bool Json::ValueInternalMap::reserve | ( | BucketIndex | newItemCount | ) |
Definition at line 265 of file json_internalmap.inl.
References Json::ValueMapAllocator::allocateMapBuckets(), and Json::mapAllocator().
Referenced by reserveDelta(), and ValueInternalMap().
bool Json::ValueInternalMap::reserveDelta | ( | BucketIndex | growth | ) |
Definition at line 259 of file json_internalmap.inl.
References reserve().
Referenced by resolveReference().
Value & Json::ValueInternalMap::resolveReference | ( | const char * | key, |
bool | isStatic | ||
) |
Definition at line 310 of file json_internalmap.inl.
References hash(), Json::ValueInternalLink::itemPerLink, Json::ValueInternalLink::next_, reserveDelta(), setNewItem(), and unsafeAdd().
Referenced by ValueInternalMap().
Value & Json::ValueInternalMap::setNewItem | ( | const char * | key, |
bool | isStatic, | ||
ValueInternalLink * | link, | ||
BucketIndex | index | ||
) |
Definition at line 419 of file json_internalmap.inl.
References Json::ValueInternalLink::items_, and Json::ValueInternalLink::keys_.
Referenced by resolveReference(), and unsafeAdd().
ValueInternalMap::BucketIndex Json::ValueInternalMap::size | ( | ) | const |
Definition at line 253 of file json_internalmap.inl.
void Json::ValueInternalMap::swap | ( | ValueInternalMap & | other | ) |
Definition at line 227 of file json_internalmap.inl.
Referenced by clear(), and operator=().
Definition at line 434 of file json_internalmap.inl.
References Json::ValueMapAllocator::allocateMapLink(), getLastLinkInBucket(), Json::ValueInternalLink::itemPerLink, Json::ValueInternalLink::items_, JSON_ASSERT_MESSAGE, Json::mapAllocator(), Json::ValueInternalLink::next_, and setNewItem().
Referenced by resolveReference().
|
friend |
|
hosts this site. |
Send comments to: Json-cpp Developers |