zkay.zkay_ast.analysis.partition_state

Module Contents

zkay.zkay_ast.analysis.partition_state.T
class zkay.zkay_ast.analysis.partition_state.PartitionState

Bases: Generic[T]

Supports operations on partitions

  • insert: create a new partition with a single element

  • merge: merge partitions

insert(self, x)
_insert_partition(self, p)
get_index(self, x: T) Optional[int]

Return index for element x.

Parameters

x

Returns

the index of the partition containing x

has(self, x: T) bool
same_partition(self, x: T, y: T) bool
merge(self, x: T, y: T)
remove(self, x: T)

Removes x from its partition

Parameters

x

Returns

move_to(self, x: T, y: T)

Moves x to the partition of y

Parameters
  • x

  • y

move_to_separate(self, x: T)

Moves x to a fresh partition

Parameters

x

separate_all(self) PartitionState[T]
join(self, other: PartitionState[T]) PartitionState[T]

Combine two states. Overlaps in partitions between self and other will be preserved. e.g. if self contains (a, b, c), (x) and other contains (a, b), (c, x), new state will contain (a, b), (c), (x)

Parameters

other – other state, must contain the same values as self (partitions can be different)

Returns

joined state

copy(self, project=None) PartitionState[T]

Create a shallow copy of the partition state.

Parameters

project – (iterator) if not None, only keep entries that are in project

Returns

__str__(self)