Infinity.AdoptedStateVector

Fields

None

Methods

class

error_quark ()

class

from_string (str)

class

from_string_diff (str, orig)

class

new ()

add (id, value)

causally_before (second)

causally_before_inc (second, inc_component)

compare (second)

copy ()

foreach (func, *user_data)

free ()

get (id)

set (id, value)

to_string ()

to_string_diff (orig)

vdiff (second)

Details

class Infinity.AdoptedStateVector

Infinity.AdoptedStateVector is an opaque data type. You should only access it via the public API functions.

classmethod error_quark()
Returns:

A #GQuark for that domain.

Return type:

int

The domain for Infinity.AdoptedStateVectorError errors.

classmethod from_string(str)
Parameters:

str (str) – A string representation of a Infinity.AdoptedStateVector.

Raises:

GLib.Error

Returns:

A new Infinity.AdoptedStateVector, or None.

Return type:

Infinity.AdoptedStateVector

Recreates the Infinity.AdoptedStateVector from its string representation. If an error occurs, the function returns None and error is set.

classmethod from_string_diff(str, orig)
Parameters:
Raises:

GLib.Error

Returns:

The created state vector, or None on error. Free with Infinity.AdoptedStateVector.free() when no longer needed.

Return type:

Infinity.AdoptedStateVector

Recreates a vector from its string representation diff and the original vector. If an error returns, the function returns None and error is set.

classmethod new()
Returns:

A new Infinity.AdoptedStateVector.

Return type:

Infinity.AdoptedStateVector

Returns a new state vector with all components set to zero.

add(id, value)
Parameters:
  • id (int) – The component to change.

  • value (int) – The value by which to change the component.

Adds value to the current value of component. value may be negative in which case the current value is actually decreased. Make sure to not drop below zero this way.

causally_before(second)
Parameters:

second (Infinity.AdoptedStateVector) – Another Infinity.AdoptedStateVector.

Returns:

Whether second depends on self.

Return type:

bool

Checks whether an event that occurred at time second is causally dependant on an event that occurred at time self, that is all components of self are less or equal to the corresponding component in second.

causally_before_inc(second, inc_component)
Parameters:
Returns:

Whether second depends on self with the inc_component th component increased by one.

Return type:

bool

This function does the equivalent of

inf_adopted_state_vector_add(first, inc_component, 1);
gboolean result = inf_adopted_state_vector_causally_before(first, second);
inf_adopted_state_vector_add(first, inc_component, -1);
return result;

But it is more efficient.

compare(second)
Parameters:

second (Infinity.AdoptedStateVector) – Another Infinity.AdoptedStateVector.

Returns:

-1, 0 or 1.

Return type:

int

Performs a comparison suited for strict-weak ordering so that state vectors can be sorted. This function returns -1 if self compares before second, 0 if they compare equal and 1 if self compares after second.

copy()
Returns:

A copy of self.

Return type:

Infinity.AdoptedStateVector

Returns a copy of self.

foreach(func, *user_data)
Parameters:

Calls func for each component in self. Note that there may be users for which func will not be called if their timestamp is 0.

free()

Frees a state vector allocated by Infinity.AdoptedStateVector.new() or Infinity.AdoptedStateVector.copy().

get(id)
Parameters:

id (int) – The component whose timestamp to look for.

Returns:

The component'th entry in the vector.

Return type:

int

Returns the timestamp for the given component. Implicitely, all IDs that the vector does not contain are assigned the timestamp 0.

set(id, value)
Parameters:
  • id (int) – The component to change.

  • value (int) – The value to set the component to.

Sets the given component of self to value.

to_string()
Returns:

A newly-allocated string to be freed by the caller.

Return type:

str

Returns a string representation of self.

to_string_diff(orig)
Parameters:

orig (Infinity.AdoptedStateVector) – Another Infinity.AdoptedStateVector.

Returns:

A newly allocated string to be freed by the caller.

Return type:

str

Returns the string representation of a diff between orig and self. This is possibly smaller than the representation created by Infinity.AdoptedStateVector.to_string(), but the same orig vector is needed to recreate self from the string representation. Additionally, Infinity.AdoptedStateVector.causally_before(orig, self) must hold.

vdiff(second)
Parameters:

second (Infinity.AdoptedStateVector) – Another Infinity.AdoptedStateVector.

Returns:

The sum of the differences between each component of self and second.

Return type:

int

This function returns the sum of the differences between each component of self and second. This function can only be called if Infinity.AdoptedStateVector.causally_before() returns True.