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.AdoptedStateVectoris 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.AdoptedStateVectorErrorerrors.
 - 
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.AdoptedStateVectorfrom its string representation. If an error occurs, the function returns- Noneand 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 - Noneon error. Free with- Infinity.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 - Noneand error is set.
- str (
 - 
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: - 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: - 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. 
- second (
 - 
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: - func (Infinity.AdoptedStateVectorForeachFunc) – The function to call.
- user_data (objectorNone) – 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. 
- func (
 - 
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: - 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.
 
- 
classmethod