Chemical Data Processing Library Python API - Version 1.2.0
Public Member Functions | Properties | List of all members
CDPL.MolProp.ElementHistogram Class Reference

A data type for the storage of element histograms of chemical compounds. More...

+ Inheritance diagram for CDPL.MolProp.ElementHistogram:

Public Member Functions

None __init__ ()
 Creates an empty map.
 
None __init__ (ElementHistogram hist)
 Initializes a copy of the ElementHistogram instance hist. More...
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
int getSize ()
 Returns the size (number of entries) of the map. More...
 
bool isEmpty ()
 Tells whether the map is empty (getSize() == 0). More...
 
None clear ()
 Erases all entries.
 
ElementHistogram assign (ElementHistogram map)
 Replaces the current state of self with a copy of the state of the ElementHistogram instance map. More...
 
int getValue (int key)
 Returns a reference to the value associated with the specified key. More...
 
int getValue (int key, int def_value)
 Returns a reference to the value associated with the specified key, or the value given by the second argument if the specified entry does not exist. More...
 
bool removeEntry (int key)
 Removes the entry specified by key from the map. More...
 
None setEntry (int key, int value)
 Inserts a new entry or updates the value of an existing entry with the specified key and value. More...
 
object getKeys ()
 
object keys ()
 
object getValues ()
 
object values ()
 
object getEntries ()
 
object items ()
 
bool containsEntry (int key)
 Tells whether the map contains an entry with the specified key. More...
 
bool insertEntry (int key, int value)
 Tries to insert a new entry with specified key and value into the map. More...
 
int __len__ ()
 
int __getitem__ (int key)
 
None __setitem__ (int key, int value)
 
bool __delitem__ (int key)
 
bool __contains__ (int key)
 Returns the result of the membership test operation key in self. More...
 
bool __eq__ (object hist)
 Returns the result of the comparison operation self == hist. More...
 
bool __ne__ (object hist)
 Returns the result of the comparison operation self != hist. More...
 
bool __le__ (object hist)
 Returns the result of the comparison operation self <= hist. More...
 
bool __ge__ (object hist)
 Returns the result of the comparison operation self >= hist. More...
 
bool __lt__ (object hist)
 Returns the result of the comparison operation self < hist. More...
 
bool __gt__ (object hist)
 Returns the result of the comparison operation self > hist. More...
 

Properties

 objectID = property(getObjectID)
 
 size = property(getSize)
 

Detailed Description

A data type for the storage of element histograms of chemical compounds.

ElementHistogram is an unique associative map where the keys specify the atom type (defined in namespace Chem.AtomType) of the chemical elements and the mapped integer values correspond to the element frequencies.

Constructor & Destructor Documentation

◆ __init__()

None CDPL.MolProp.ElementHistogram.__init__ ( ElementHistogram  hist)

Initializes a copy of the ElementHistogram instance hist.

Parameters
histThe ElementHistogram instance to copy.

Member Function Documentation

◆ getObjectID()

int CDPL.MolProp.ElementHistogram.getObjectID ( )

Returns the numeric identifier (ID) of the wrapped C++ class instance.

Different Python ElementHistogram instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two ElementHistogram instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().

Returns
The numeric ID of the internally referenced C++ class instance.

◆ getSize()

int CDPL.MolProp.ElementHistogram.getSize ( )

Returns the size (number of entries) of the map.

Returns
The size of the map.

◆ isEmpty()

bool CDPL.MolProp.ElementHistogram.isEmpty ( )

Tells whether the map is empty (getSize() == 0).

Returns
True if the map is empty, and False otherwise.

◆ assign()

ElementHistogram CDPL.MolProp.ElementHistogram.assign ( ElementHistogram  map)

Replaces the current state of self with a copy of the state of the ElementHistogram instance map.

Parameters
mapThe ElementHistogram instance to copy.
Returns
self

◆ getValue() [1/2]

int CDPL.MolProp.ElementHistogram.getValue ( int  key)

Returns a reference to the value associated with the specified key.

If the map contains the specified entry, a reference to the associated value is returned. If the map does not contain the entry and default values are enabled (that is, the template parameter AllowDefValues is True), a reference to a default constructed value object is returned. Otherwise, Base.ItemNotFound is thrown to indicate the error.

Parameters
keyThe key associated with the requested value.
Returns
A reference to the requested value.
Exceptions
Base.ItemNotFoundif AllowDefValues is False and the map does not contain an entry with the specified key.

◆ getValue() [2/2]

int CDPL.MolProp.ElementHistogram.getValue ( int  key,
int  def_value 
)

Returns a reference to the value associated with the specified key, or the value given by the second argument if the specified entry does not exist.

If the map contains an entry with the specified key, a reference to the associated value is returned. If the map does not contain the entry, the second argument def_value is returned.

Parameters
keyThe key associated with the requested value.
def_valueThe value which is returned if the specified entry does not exist.
Returns
A reference to the requested or default value.

◆ removeEntry()

bool CDPL.MolProp.ElementHistogram.removeEntry ( int  key)

Removes the entry specified by key from the map.

Parameters
keyThe key specifying the entry to remove.

◆ setEntry()

None CDPL.MolProp.ElementHistogram.setEntry ( int  key,
int  value 
)

Inserts a new entry or updates the value of an existing entry with the specified key and value.

If the map does not already contain an entry whose key is the same as key then a new entry will be created. Otherwise, the value of the existing entry is updated with value. The return value is a dereferenceable iterator that points to the newly inserted or updated entry whose key is equivalent to the specified key.

Parameters
keyThe key of the entry to insert or update.
valueThe value to be associated with key.
Returns
An iterator that points to the newly inserted or updated entry.

◆ getKeys()

object CDPL.MolProp.ElementHistogram.getKeys ( )
Returns

◆ keys()

object CDPL.MolProp.ElementHistogram.keys ( )
Returns

◆ getValues()

object CDPL.MolProp.ElementHistogram.getValues ( )
Returns

◆ values()

object CDPL.MolProp.ElementHistogram.values ( )
Returns

◆ getEntries()

object CDPL.MolProp.ElementHistogram.getEntries ( )
Returns

◆ items()

object CDPL.MolProp.ElementHistogram.items ( )
Returns

◆ containsEntry()

bool CDPL.MolProp.ElementHistogram.containsEntry ( int  key)

Tells whether the map contains an entry with the specified key.

Parameters
keyThe key specifying the entry.
Returns
True if the map contains the specified entry, and False otherwise.

◆ insertEntry()

bool CDPL.MolProp.ElementHistogram.insertEntry ( int  key,
int  value 
)

Tries to insert a new entry with specified key and value into the map.

Inserts a new entry if and only if the map does not already contain an entry whose key is the same as the specified key. The return value is a pair P. P.first is an iterator pointing to the entry whose key is the same as the specified key. P.second is a boolean value which is True if item was actually inserted, and False if the map already contained an entry with the specified key.

Parameters
keyThe key of the entry to insert.
valueThe value associated with key.
Returns
A std::pair consisting of an iterator pointing to an entry whose key is the same as key and a boolean value, which is True if the insertion of item was successful (an entry with the specified key did not already exist), and False otherwise.

◆ __len__()

int CDPL.MolProp.ElementHistogram.__len__ ( )
Returns

◆ __getitem__()

int CDPL.MolProp.ElementHistogram.__getitem__ ( int  key)
Parameters
key
Returns

◆ __setitem__()

None CDPL.MolProp.ElementHistogram.__setitem__ ( int  key,
int  value 
)
Parameters
key
value

◆ __delitem__()

bool CDPL.MolProp.ElementHistogram.__delitem__ ( int  key)
Parameters
key
Returns

◆ __contains__()

bool CDPL.MolProp.ElementHistogram.__contains__ ( int  key)

Returns the result of the membership test operation key in self.

Parameters
keyThe value to test for membership.
Returns
The result of the membership test operation.

◆ __eq__()

bool CDPL.MolProp.ElementHistogram.__eq__ ( object  hist)

Returns the result of the comparison operation self == hist.

Parameters
histThe object instance to be compared with.
Returns
The result of the comparison operation.

◆ __ne__()

bool CDPL.MolProp.ElementHistogram.__ne__ ( object  hist)

Returns the result of the comparison operation self != hist.

Parameters
histThe object instance to be compared with.
Returns
The result of the comparison operation.

◆ __le__()

bool CDPL.MolProp.ElementHistogram.__le__ ( object  hist)

Returns the result of the comparison operation self <= hist.

Parameters
histThe object instance to be compared with.
Returns
The result of the comparison operation.

◆ __ge__()

bool CDPL.MolProp.ElementHistogram.__ge__ ( object  hist)

Returns the result of the comparison operation self >= hist.

Parameters
histThe object instance to be compared with.
Returns
The result of the comparison operation.

◆ __lt__()

bool CDPL.MolProp.ElementHistogram.__lt__ ( object  hist)

Returns the result of the comparison operation self < hist.

Parameters
histThe object instance to be compared with.
Returns
The result of the comparison operation.

◆ __gt__()

bool CDPL.MolProp.ElementHistogram.__gt__ ( object  hist)

Returns the result of the comparison operation self > hist.

Parameters
histThe object instance to be compared with.
Returns
The result of the comparison operation.