Oracle Coherence for C++ API


SafeHashMap::Entry Class Reference

#include <coherence/util/SafeHashMap.hpp>

Inherits Object.

List of all members.

Detailed Description

A map entry (key-value pair).

The Map.entrySet method returns a collection-view of the map, whose elements are of this class.

Public Types

typedef spec::Handle Handle
 Entry Handle definition.
typedef spec::View View
 Entry View definition.
typedef spec::Holder Holder
 Entry Holder definition.

Public Member Functions

virtual bool isKeyEqual (Object::View vKey) const
 Return true if the supplied key is equal to the entries key.
virtual Object::View getKey () const
virtual Object::Holder getValue () const
virtual Object::Holder getValue ()
virtual Object::Holder setValue (Object::Holder ohValue)
virtual void onAdd ()
 This method is invoked when the containing Map has actually added this Entry to itself.
virtual bool equals (Object::View vThat) const
virtual size32_t hashCode () const
 Return a hash code value for the Object.

This method is supported for the benefit of hash-based containers.

The general contract of hashCode is:

  • Whenever it is invoked on the same Object more than once during an execution of an application, the hashCode method must consistently return the same value, provided no information used in equals comparisons on the object is modified. This value need not remain consistent from one execution of an application to another execution of the same application.
  • If two Objects are equal according to the equals method, then calling the hashCode method on each of the two Objects must produce the same value.
  • It is not required that if two Objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct results. However, the programmer should be aware that producing distinct results for unequal objects may improve the performance of hash-based containers.

The default implementation is identity based.

a hash code value for this Object

virtual void toStream (std::ostream &out) const
 Output a human-readable description of this Object to the given stream.

coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toStream method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents.

 Object::View vKey   = ...
 Object::View vValue = ...
 std::cout << vKey << " = " << vValue << std::endl;

 String::Handle hs = COH_TO_STRING(vKey << " = " << vValue);

out the stream used to output the description

Protected Member Functions

 Entry (Object::View vKey, Object::Holder ohValue, size32_t nHash)
 Create a new Map::Entry.
 Entry (const Entry &that)
 Copy Constructor.
 Entry (Entry::View vThat)
 Instantiate an Entry shallow copying the key and value from the Entry provided.

Protected Attributes

FinalView< Objectm_vKey
 The key.
MemberHolder< Objectm_ohValue
 The value.
const size32_t m_nHash
 The key's hash code.
MemberHandle< Entrym_hNext
 The next entry in the linked list (an open hashing implementation).

Constructor & Destructor Documentation

Entry ( Object::View  vKey,
Object::Holder  ohValue,
size32_t  nHash 
) [protected]

Create a new Map::Entry.

vKey the assocaited key
ohValue the associated value
hHash the associated hash code
a new Map::Entry

Entry ( Entry::View  vThat  )  [protected]

Instantiate an Entry shallow copying the key and value from the Entry provided.

vThat the entry to copy from

Member Data Documentation

MemberHolder<Object> m_ohValue [protected]

The value.

This object reference can change within the life of the Entry.

const size32_t m_nHash [protected]

The key's hash code.

This value will not change for the life of the Entry.

The documentation for this class was generated from the following file:
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.