WISP ERT (Server)  1.0.0
The WISP Extended Runtime (Server side)
wtp.util.CyclicInt Class Reference

Cyclic integer type. More...

Inheritance diagram for wtp.util.CyclicInt:

Public Member Functions

def __init__ (self, value, radix)
 Cyclic integer type constructor. More...
 
def __eq__ (self, other)
 Compare equality of cyclic integer with another value. More...
 
def __lt__ (self, other)
 Compare if a cyclic integer is smaller than another value. More...
 
def __gt__ (self, other)
 Compare if a cyclic integer is bigger than another value. More...
 
def __add__ (self, other)
 Add cyclic integer with another value. More...
 
def __radd__ (self, other)
 Add cyclic integer with another value. More...
 
def __sub__ (self, other)
 Subtract a value from self. More...
 
def __neg__ (self)
 Get supplementary cyclic integer. More...
 
def __int__ (self)
 Convert a cyclic integer to built-in integer. More...
 
def __index__ (self)
 Convert cyclic integer to collection index. More...
 
def __repr__ (self)
 Representation of cyclic integer. More...
 
def as_zero (self)
 Enter a context with this cyclic integer as zero point. More...
 

Private Member Functions

def _zero_ctx (cls)
 Get current zero point context. More...
 

Private Attributes

 _value
 Value. More...
 
 _radix
 Radix. More...
 

Static Private Attributes

list _zero_ctx_stack = []
 Zero point contexts stack. More...
 

Detailed Description

Cyclic integer type.

Constructor & Destructor Documentation

◆ __init__()

def wtp.util.CyclicInt.__init__ (   self,
  value,
  radix 
)

Cyclic integer type constructor.

Parameters
valueValue of the cyclic integer.
radixRadix of the cyclic integer.

Member Function Documentation

◆ __add__()

def wtp.util.CyclicInt.__add__ (   self,
  other 
)

Add cyclic integer with another value.

Parameters
otherOther value.
Returns
A cyclic sum of the two values.

◆ __eq__()

def wtp.util.CyclicInt.__eq__ (   self,
  other 
)

Compare equality of cyclic integer with another value.

Parameters
otherOther value.
Returns
Whether two cyclic integer is equal or not.

◆ __gt__()

def wtp.util.CyclicInt.__gt__ (   self,
  other 
)

Compare if a cyclic integer is bigger than another value.

You should enter a zero context before comparing two cyclic integers.

Parameters
otherOther value.
Returns
Whether this cyclic integer is bigger than the other value.

◆ __index__()

def wtp.util.CyclicInt.__index__ (   self)

Convert cyclic integer to collection index.

(Proxied to self.__int__)

Returns
Corresponding Python integer.

◆ __int__()

def wtp.util.CyclicInt.__int__ (   self)

Convert a cyclic integer to built-in integer.

Returns
Corresponding Python integer.

◆ __lt__()

def wtp.util.CyclicInt.__lt__ (   self,
  other 
)

Compare if a cyclic integer is smaller than another value.

You should enter a zero context before comparing two cyclic integers.

Parameters
otherOther value.
Returns
Whether this cyclic integer is smaller than the other value.

◆ __neg__()

def wtp.util.CyclicInt.__neg__ (   self)

Get supplementary cyclic integer.

Returns
Supplementary cyclic integer.

◆ __radd__()

def wtp.util.CyclicInt.__radd__ (   self,
  other 
)

Add cyclic integer with another value.

(Proxied to self.__add__)

Parameters
otherOther value.
Returns
A cyclic sum of the two values.

◆ __repr__()

def wtp.util.CyclicInt.__repr__ (   self)

Representation of cyclic integer.

Returns
A readable representation of the cyclic integer.

◆ __sub__()

def wtp.util.CyclicInt.__sub__ (   self,
  other 
)

Subtract a value from self.

Parameters
otherOther value
Returns
A cyclic difference of the two values.

◆ _zero_ctx()

def wtp.util.CyclicInt._zero_ctx (   cls)
private

Get current zero point context.

Returns
Current zero point context.
Exceptions
Exceptionif not in a zero point context.

◆ as_zero()

def wtp.util.CyclicInt.as_zero (   self)

Enter a context with this cyclic integer as zero point.

(The old zero context will be saved in a zero context stack)

Member Data Documentation

◆ _radix

wtp.util.CyclicInt._radix
private

Radix.

◆ _value

wtp.util.CyclicInt._value
private

Value.

◆ _zero_ctx_stack

list wtp.util.CyclicInt._zero_ctx_stack = []
staticprivate

Zero point contexts stack.


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