Chemical Data Processing Library Python API - Version 1.4.0
Public Member Functions | Properties | List of all members
CDPL.Math.Range Class Reference

Half-open index range \( [start, stop) \) used for slicing vector and matrix expressions. More...

+ Inheritance diagram for CDPL.Math.Range:

Public Member Functions

None __init__ ()
 Constructs an empty range \( [0, 0) \).
 
None __init__ (Range r)
 Initializes a copy of the Range instance r. More...
 
None __init__ (int start, int stop)
 Constructs the range \( [start, stop) \). More...
 
int getStart ()
 Returns the lower (inclusive) bound. More...
 
int getStop ()
 Returns the upper (exclusive) bound. More...
 
int getSize ()
 Returns the size of the range, \( stop - start \). More...
 
bool isEmpty ()
 Tells whether the range is empty. More...
 
int getIndex (int i)
 
Range assign (Range r)
 Replaces the current state of self with a copy of the state of the Range instance r. More...
 
None swap (Range r)
 Swaps the contents of self and r. More...
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
bool __eq__ (Range r)
 Equality comparison. More...
 
bool __ne__ (Range r)
 Inequality comparison. More...
 
int __call__ (int i)
 Maps the local position i to the global index start + i. More...
 
int __getitem__ (int i)
 

Properties

 objectID = property(getObjectID)
 
 start = property(getStart)
 
 stop = property(getStop)
 
 size = property(getSize)
 

Detailed Description

Half-open index range \( [start, stop) \) used for slicing vector and matrix expressions.

Constructor & Destructor Documentation

◆ __init__() [1/2]

None CDPL.Math.Range.__init__ ( Range  r)

Initializes a copy of the Range instance r.

Parameters
rThe Range instance to copy.

◆ __init__() [2/2]

None CDPL.Math.Range.__init__ ( int  start,
int  stop 
)

Constructs the range \( [start, stop) \).

Parameters
startThe lower (inclusive) bound.
stopThe upper (exclusive) bound.
Exceptions
Base.RangeErrorif start > stop.

Member Function Documentation

◆ getStart()

int CDPL.Math.Range.getStart ( )

Returns the lower (inclusive) bound.

Returns
The lower bound.

◆ getStop()

int CDPL.Math.Range.getStop ( )

Returns the upper (exclusive) bound.

Returns
The upper bound.

◆ getSize()

int CDPL.Math.Range.getSize ( )

Returns the size of the range, \( stop - start \).

Returns
The range size.

◆ isEmpty()

bool CDPL.Math.Range.isEmpty ( )

Tells whether the range is empty.

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

◆ getIndex()

int CDPL.Math.Range.getIndex ( int  i)
Parameters
i
Returns

◆ assign()

Range CDPL.Math.Range.assign ( Range  r)

Replaces the current state of self with a copy of the state of the Range instance r.

Parameters
rThe Range instance to copy.
Returns
self

◆ swap()

None CDPL.Math.Range.swap ( Range  r)

Swaps the contents of self and r.

Parameters
rThe other range.

◆ getObjectID()

int CDPL.Math.Range.getObjectID ( )

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

Different Python Range 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 Range 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.

◆ __eq__()

bool CDPL.Math.Range.__eq__ ( Range  r)

Equality comparison.

Parameters
rThe other range.
Returns
True if both ranges have the same start and stop, and False otherwise.

◆ __ne__()

bool CDPL.Math.Range.__ne__ ( Range  r)

Inequality comparison.

Parameters
rThe other range.
Returns
True if the ranges differ in start or stop, and False otherwise.

◆ __call__()

int CDPL.Math.Range.__call__ ( int  i)

Maps the local position i to the global index start + i.

Parameters
iThe zero-based local position.
Returns
The global index.
Exceptions
Base.IndexErrorif i is not in the range \( [0, size) \).

◆ __getitem__()

int CDPL.Math.Range.__getitem__ ( int  i)
Parameters
i
Returns