1.6. Utilities

1.6.1. Containers

Raysect has a number of container classes available for fast operations in cython. These are mainly intended for use by developers.

class raysect.core.containers.LinkedList

Basic implementation of a Linked List for fast container operations in cython.

Parameters

initial_items (object) – Optional iterable for initialising container.

Variables
  • length (int) – number of items in the container

  • first – starting element of container

  • last – final element of container

add()

Add an item to the end of the container.

Parameters

value (object) – The item to add to the end of the container.

add_items()

Extend this container with another iterable container.

Parameters

iterable (object) – Iterable object such as a list or ndarray with which to extend this container.

get_index()

Get the item from the container at specified index.

Parameters

index (int) – requested item index

insert()

Insert an item at the specified index.

Parameters
  • value (object) – item to insert

  • index (int) – index at which to insert this item

is_empty()

Returns True if the container is empty.

remove()

Remove and return the specified item from the container.

Parameters

index (int) – Index at which an item will be removed.

Returns

The object at the specified index position.

class raysect.core.containers.Stack

Bases: raysect.core.containers.LinkedList

Basic implementation of a Stack container for fast container operations in cython. Inherits attributes and methods from LinkedList.

pop()

Removes and returns the most recently added item from the stack

Return type

object

push()

Adds an item to the top of the stack

Parameters

value (object) – Object that will be pushed to top of the stack

class raysect.core.containers.Queue

Bases: raysect.core.containers.LinkedList

Basic implementation of a Queue container for fast container operations in cython. Inherits attributes and methods from LinkedList.

next_in_queue()

Returns the next object in the queue

Return type

object