Textbook ADT Notation
The abstract data type (ADT) definitions throughout the text include some operations that are suppose to be implemented using a Python operator. Those methods are specified using an {+''italicized''+} font. The table below maps the various ADT operations to the corresponding Python operator method that is suppose to be used in the implementation.
[table align='center' cellpadding='4' cellspacing='2'] [row bgcolor=#202020] [c style='color:white;'] '''ADT Operation''' [c style='color:white;'] '''How is it Used''' [c style='color:white;'] '''Python Operator Method''' [c style='color:white;'] '''What it Returns''' [row] [l] ''absolute()'' [l] @@abs(obj)@@ [l] @@__abs__(self)@@ [l] New object of the same type. [row bgcolor='#E0E0E0'] [l] ''add( rhsObj )'' [l] @@y = x + rhsObj)@@ [l] @@__add__( self, rhsObj )@@ [l] New object of the same type. [row valign='top'] [l] ''comparable(rhsObj)'' [l] @@x == y@@, @@x < y@@,\ @@x <= y@@, @@x != y@@,\ @@x >= y@@, @@x > y@@ [l] @@__eq__( self, rhsObj )@@\ @@__lt__( self, rhsObj )@@\ @@__le__( self, rhsObj )@@ [l] true or false [row bgcolor='#E0E0E0'] [l] ''contains( item )'' [l] @@item in obj@@ [l] @@__contains__( self, item )@@ [l] true or false [row] [l] ''divide( rhsObj )'' [l] @@y = x / rhsObj@@ [l] @@__truediv__(self, rhsObj)@@ [l] New object of the same type. [row bgcolor='#E8E8E8'] [l] ''equal( rhsObj )'' [l] @@x == rhsObj@@ [l] @@__eq__( self, rhsObj )@@ [l] true or false [row] [l] ''getitem( index )'' [l] @@y = obj[index]@@ [l] @@__getitem__( self, index )@@ [l] An object from the container. [row] [row bgcolor='#E0E0E0'] [l] ''length()'' [l] @@len(obj)@@ [l] @@__len__( self ) @@ [l] An integer value. [row] [l] ''multiply( rhsObj )'' [l] @@y = x * rhsObj@@ [l] @@__mul__( self, rhsObj )@@ [l] New object of the same type. [row bgcolor='#E0E0E0'] [l] ''negate()'' [l] @@y = -x@@ [l] @@__neg__( self )@@ [l] New object of the same type. [row] [l] ''setitem(index, value)'' [l] @@x[index] = value@@ [l] @@__setitem__(self, index, value)@@ [l] Nothing. [row bgcolor='#E0E0E0'] [l] ''subtract( rhsObj )'' [l] @@y = x - rhsObj@@ [l] @@__sub__( self, rhsObj )@@ [l] New object of the same type. [row] [l] ''toFloat()'' [l] @@float(obj)@@ [l] @@__float__( self )@@ [l] Floating point value. [row bgcolor='#E0E0E0'] [l] ''toInt()'' [l] @@int(obj)@@ [l] @@__int__( self )@@ [l] An integer value. [row] [l] ''toString()'' [l] @@str(obj)@@ [l] @@__repr__( self )@@ [l] A string. [tableend]