u-RPC (Python API)  1.0.1
The u-RPC Remote Procedure Call framework
urpc.util.AllocTable Class Reference

The allocation table data structure. More...

Inheritance diagram for urpc.util.AllocTable:

Public Member Functions

def __init__ (self, capacity)
 Initialize the allocation table. More...
 
def __len__ (self)
 Get number of elements in the table. More...
 
def __getitem__ (self, index)
 Get value by index. More...
 
def __setitem__ (self, index, value)
 Set value by index. More...
 
def __delitem__ (self, index)
 Remove a value from the table by its index. More...
 
def add (self, value)
 Add a value to the table and return its corresponding index. More...
 
def get (self, index, default=None)
 Get value by index. More...
 

Private Attributes

 _capacity
 Capacity of elements. More...
 
 _size
 Number of elements. More...
 
 _spare_begin
 Begin of the spare table items linked list. More...
 
 _store
 Internal data store. More...
 

Detailed Description

The allocation table data structure.

Constructor & Destructor Documentation

◆ __init__()

def urpc.util.AllocTable.__init__ (   self,
  capacity 
)

Initialize the allocation table.

Parameters
capacityCapacity of the allocation table.

Member Function Documentation

◆ __delitem__()

def urpc.util.AllocTable.__delitem__ (   self,
  index 
)

Remove a value from the table by its index.

Parameters
indexIndex of the value

◆ __getitem__()

def urpc.util.AllocTable.__getitem__ (   self,
  index 
)

Get value by index.

Parameters
indexIndex of the value.
Returns
The value.

◆ __len__()

def urpc.util.AllocTable.__len__ (   self)

Get number of elements in the table.

Returns
Number of elements in the table.

◆ __setitem__()

def urpc.util.AllocTable.__setitem__ (   self,
  index,
  value 
)

Set value by index.

Parameters
indexIndex of the value.
valueNew value to set.

◆ add()

def urpc.util.AllocTable.add (   self,
  value 
)

Add a value to the table and return its corresponding index.

Parameters
valueValue to be added.
Returns
Index of the value.

◆ get()

def urpc.util.AllocTable.get (   self,
  index,
  default = None 
)

Get value by index.

(Fallback to default if index corresponds with a spare item)

Parameters
indexIndex of the value.
defaultDefault value if item is spare.
Returns
The value.

Member Data Documentation

◆ _capacity

urpc.util.AllocTable._capacity
private

Capacity of elements.

◆ _size

urpc.util.AllocTable._size
private

Number of elements.

◆ _spare_begin

urpc.util.AllocTable._spare_begin
private

Begin of the spare table items linked list.

◆ _store

urpc.util.AllocTable._store
private

Internal data store.


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