JX Application Framework
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Friends | List of all members
JStringMap< V > Class Template Reference

#include <JStringMap.h>

Inheritance diagram for JStringMap< V >:
[legend]

Public Member Functions

 JStringMap (const JSize lgSize=kJDefaultLgMinTableSize)
 
 ~JStringMap () override
 
bool Contains (const JString &key) const
 
bool GetItem (const JString &key, V *value) const
 
bool SetItem (const JString &key, const V &value, const JStringMapT::SetType type=JStringMapT::kAlways)
 
bool SetNewItem (const JString &key, const V &value)
 
bool SetOldItem (const JString &key, const V &value)
 
bool SetContains (const JString &key, const V &value)
 
bool RemoveItem (const JString &key)
 
void RemoveAll ()
 
bool Contains (const JUtf8Byte *key) const
 
bool GetItem (const JUtf8Byte *key, V *value) const
 
bool SetItem (const JUtf8Byte *key, const V &value, const JStringMapT::SetType type=JStringMapT::kAlways)
 
bool SetNewItem (const JUtf8Byte *key, const V &value)
 
bool SetOldItem (const JUtf8Byte *key, const V &value)
 
bool SetContains (const JUtf8Byte *key, const V &value)
 
bool RemoveItem (const JUtf8Byte *key)
 
- Public Member Functions inherited from JHashTable< JStrValue< V > >
 JHashTable (const JSize lgSize=kJDefaultLgMinTableSize)
 
virtual ~JHashTable ()
 
bool IsEmpty () const
 
JSize GetItemCount () const
 
JSize GetLgSize () const
 
JSize GetLoadCount () const
 
JSize GetTableSize () const
 
JFloat GetFillFactor () const
 
JFloat GetLoadFactor () const
 
bool GetResizeEnabled () const
 
void SetResizeEnabled (const bool enabled)
 
JFloat GetMaxLoadFactor () const
 
void SetMaxLoadFactor (const JFloat newMax)
 
JFloat GetMinFillFactor () const
 
void SetMinFillFactor (const JFloat newMin)
 
JSize GetMinTableSize () const
 
void SetMinTableSize (const JSize newMin)
 
bool IsOK () const
 

Protected Member Functions

bool SetItem (const JString &key, const V &value, const JPtrArrayT::SetAction action, const JStringMapT::SetType type, bool *existed)
 
virtual void PrepareForSet (const JPtrArrayT::SetAction action)
 
bool RemoveItem (const JString &key, const JPtrArrayT::SetAction action)
 
void RemoveAll (const JPtrArrayT::SetAction action)
 
- Protected Member Functions inherited from JHashTable< JStrValue< V > >
bool IsEmpty (const JSize index) const
 
void AllowCursors ()
 
void DisallowCursors ()
 
JHashCursor< JStrValue< V > > * GetCursor ()
 
JConstHashCursor< JStrValue< V > > * GetCursor () const
 
const JHashRecord< JStrValue< V > > & GetRecord (const JSize index) const
 
JHashRecordT::State GetState (const JSize index) const
 
bool IsDeleted (const JSize index) const
 
bool IsFull (const JSize index) const
 
JHashValue GetHashValue (const JSize index) const
 
const JStrValue< V > & GetValue (const JSize index) const
 
void Set (const JSize index, const JHashRecord< JStrValue< V > > &record)
 
void Set (const JSize index, const JHashValue hash, const JStrValue< V > &value)
 
void Set (const JSize index, const JStrValue< V > &value)
 
void SetHash (const JSize index, const JStrValue< V > &value)
 
void Remove (const JSize index)
 
void MarkEmpty (const JSize index)
 
void MarkAllEmpty ()
 
bool TryResizeTable (const JSize lgSize)
 
void ResizeTable (const JSize lgTrialSize)
 
virtual bool FitToLimits (const JSize required=0, const bool force=false)
 
JSize HashToIndex (JHashValue hash) const
 

Friends

class JStringMapCursor< V >
 

Detailed Description

template<class V>
class JStringMap< V >

Interface for the JStringMapCursor class.

Base code generated by Codemill v0.1.0

Constructor & Destructor Documentation

◆ JStringMap()

template<class V >
JStringMap< V >::JStringMap ( const JSize  lgSize = kJDefaultLgMinTableSize)

Base code generated by Codemill v0.1.0

◆ ~JStringMap()

template<class V >
JStringMap< V >::~JStringMap ( )
override

Member Function Documentation

◆ Contains() [1/2]

template<class V >
bool JStringMap< V >::Contains ( const JString key) const

This code is also used to position the cursor for use by other functions in both this class and derived classes!

◆ Contains() [2/2]

template<class V >
bool JStringMap< V >::Contains ( const JUtf8Byte key) const
inline

◆ GetItem() [1/2]

template<class V >
bool JStringMap< V >::GetItem ( const JString key,
V *  value 
) const

If the element is found, sets value to it and returns true; otherwise, leaves value unmodified and returns false.

◆ GetItem() [2/2]

template<class V >
bool JStringMap< V >::GetItem ( const JUtf8Byte key,
V *  value 
) const
inline

◆ PrepareForSet()

template<class V >
void JStringMap< V >::PrepareForSet ( const JPtrArrayT::SetAction  action)
protectedvirtual

Operates on the cursor's element.

Reimplemented in JStringPtrMap< V >, JStringPtrMap< JString >, and JStringPtrMap< JXImage >.

◆ RemoveAll() [1/2]

template<class V >
void JStringMap< V >::RemoveAll ( )
inline

◆ RemoveAll() [2/2]

template<class V >
void JStringMap< V >::RemoveAll ( const JPtrArrayT::SetAction  action)
protected

◆ RemoveItem() [1/3]

template<class V >
bool JStringMap< V >::RemoveItem ( const JString key)
inline

◆ RemoveItem() [2/3]

template<class V >
bool JStringMap< V >::RemoveItem ( const JString key,
const JPtrArrayT::SetAction  action 
)
protected

◆ RemoveItem() [3/3]

template<class V >
bool JStringMap< V >::RemoveItem ( const JUtf8Byte key)
inline

◆ SetContains() [1/2]

template<class V >
bool JStringMap< V >::SetContains ( const JString key,
const V &  value 
)
inline

◆ SetContains() [2/2]

template<class V >
bool JStringMap< V >::SetContains ( const JUtf8Byte key,
const V &  value 
)
inline

A sometimes useful hybrid form; always sets the element, and returns true if the element already existed, false otherwise.

◆ SetItem() [1/3]

template<class V >
bool JStringMap< V >::SetItem ( const JString key,
const V &  value,
const JPtrArrayT::SetAction  action,
const JStringMapT::SetType  type,
bool existed 
)
protected

The element is set if it already existed and 'type' is kIfOld or kAlways (the default) or if it did not exist and 'type' is kIfNew or kAlways.

Returns true if the element was set, false otherwise. existed is set to true if there was something already there.

◆ SetItem() [2/3]

template<class V >
bool JStringMap< V >::SetItem ( const JString key,
const V &  value,
const JStringMapT::SetType  type = JStringMapT::kAlways 
)
inline

◆ SetItem() [3/3]

template<class V >
bool JStringMap< V >::SetItem ( const JUtf8Byte key,
const V &  value,
const JStringMapT::SetType  type = JStringMapT::kAlways 
)
inline

The basic idea of setting a map element is simple. However, it is common to write code which will set a value depending on whether it already exists. Several forms of Set...Element support this notion more efficiently than calling Contains() and then SetItem(). In particular, the hash calculation and internal search will only happen once. The element is set if it already existed and 'type' is kIfOld or kAlways (the default) or if it did not exist and 'type' is kIfNew or kAlways.

Returns true if the element was set, false otherwise.

◆ SetNewItem() [1/2]

template<class V >
bool JStringMap< V >::SetNewItem ( const JString key,
const V &  value 
)
inline

◆ SetNewItem() [2/2]

template<class V >
bool JStringMap< V >::SetNewItem ( const JUtf8Byte key,
const V &  value 
)
inline

Only sets the value if it does not already exist. Returns true if the value was set.

◆ SetOldItem() [1/2]

template<class V >
bool JStringMap< V >::SetOldItem ( const JString key,
const V &  value 
)
inline

◆ SetOldItem() [2/2]

template<class V >
bool JStringMap< V >::SetOldItem ( const JUtf8Byte key,
const V &  value 
)
inline

Only sets the value if it already exists. Returns true if the value was set.

Friends And Related Symbol Documentation

◆ JStringMapCursor< V >

template<class V >
friend class JStringMapCursor< V >
friend

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