JsonCpp project page JsonCpp home page

Public Types | Public Member Functions | Friends | List of all members
Json::ValueInternalMap Class Reference

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)
 
ValueInternalMapoperator= (const ValueInternalMap &other)
 
 ~ValueInternalMap ()
 
void swap (ValueInternalMap &other)
 
BucketIndex size () const
 
void clear ()
 
bool reserveDelta (BucketIndex growth)
 
bool reserve (BucketIndex newItemCount)
 
const Valuefind (const char *key) const
 
Valuefind (const char *key)
 
ValueresolveReference (const char *key, bool isStatic)
 
void remove (const char *key)
 
void doActualRemove (ValueInternalLink *link, BucketIndex index, BucketIndex bucketIndex)
 
ValueInternalLink *& getLastLinkInBucket (BucketIndex bucketIndex)
 
ValuesetNewItem (const char *key, bool isStatic, ValueInternalLink *link, BucketIndex index)
 
ValueunsafeAdd (const char *key, bool isStatic, HashKey hashedKey)
 
HashKey hash (const char *key) const
 
int compare (const ValueInternalMap &other) const
 

Friends

class ValueIteratorBase
 
class Value
 

Detailed Description

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.

Definition at line 664 of file value.h.

Member Typedef Documentation

Definition at line 670 of file value.h.

typedef unsigned int Json::ValueInternalMap::HashKey

Definition at line 669 of file value.h.

Constructor & Destructor Documentation

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 ( )

Member Function Documentation

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 
)
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_.

Referenced by compare(), and find().

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)
bool Json::ValueInternalMap::reserve ( BucketIndex  newItemCount)
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 
)
Value & Json::ValueInternalMap::setNewItem ( const char *  key,
bool  isStatic,
ValueInternalLink link,
BucketIndex  index 
)
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=().

Value & Json::ValueInternalMap::unsafeAdd ( const char *  key,
bool  isStatic,
HashKey  hashedKey 
)

Friends And Related Function Documentation

friend class Value
friend

Definition at line 667 of file value.h.

friend class ValueIteratorBase
friend

Definition at line 666 of file value.h.


The documentation for this class was generated from the following files:

SourceForge Logo hosts this site. Send comments to:
Json-cpp Developers