Infinity.AdoptedStateVector¶
Fields¶
None
Methods¶
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
The domain for
Infinity.AdoptedStateVectorError
errors.
- classmethod from_string(str)¶
- Parameters:
str (
str
) – A string representation of aInfinity.AdoptedStateVector
.- Raises:
- Returns:
A new
Infinity.AdoptedStateVector
, orNone
.- Return type:
Recreates the
Infinity.AdoptedStateVector
from its string representation. If an error occurs, the function returnsNone
and error is set.
- classmethod from_string_diff(str, orig)¶
- Parameters:
str (
str
) – A string representation of a diff between state vectors.orig (
Infinity.AdoptedStateVector
) – The state vector used to create str inInfinity.AdoptedStateVector.to_string_diff
().
- Raises:
- Returns:
The created state vector, or
None
on error. Free withInfinity.AdoptedStateVector.free
() when no longer needed.- Return type:
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:
Returns a new state vector with all components set to zero.
- add(id, value)¶
- Parameters:
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
) – AnotherInfinity.AdoptedStateVector
.- Returns:
Whether second depends on self.
- Return type:
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:
second (
Infinity.AdoptedStateVector
) – AnotherInfinity.AdoptedStateVector
.inc_component (
int
) – The component to increment before comparing.
- Returns:
Whether second depends on self with the inc_component th component increased by one.
- Return type:
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
) – AnotherInfinity.AdoptedStateVector
.- Returns:
-1, 0 or 1.
- Return type:
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:
Returns a copy of self.
- foreach(func, *user_data)¶
- Parameters:
func (
Infinity.AdoptedStateVectorForeachFunc
) – The function to call.user_data (
object
orNone
) – Additional data to pass to func.
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
() orInfinity.AdoptedStateVector.copy
().
- get(id)¶
- Parameters:
id (
int
) – The component whose timestamp to look for.- Returns:
The component'th entry in the vector.
- Return type:
Returns the timestamp for the given component. Implicitely, all IDs that the vector does not contain are assigned the timestamp 0.
- set(id, value)¶
-
Sets the given component of self to value.
- to_string()¶
- Returns:
A newly-allocated string to be freed by the caller.
- Return type:
Returns a string representation of self.
- to_string_diff(orig)¶
- Parameters:
orig (
Infinity.AdoptedStateVector
) – AnotherInfinity.AdoptedStateVector
.- Returns:
A newly allocated string to be freed by the caller.
- Return type:
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
) – AnotherInfinity.AdoptedStateVector
.- Returns:
The sum of the differences between each component of self and second.
- Return type:
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
() returnsTrue
.