Struct CMap3

Source
pub struct CMap3<T: CoordsFloat> { /* private fields */ }
Expand description

Main map object.

Implementations§

Source§

impl<T: CoordsFloat> CMap3<T>

Dart-related methods

Source

pub fn n_darts(&self) -> usize

Return the current number of darts.

Source

pub fn n_unused_darts(&self) -> usize

Return the current number of unused darts.

Source

pub fn add_free_dart(&mut self) -> DartIdType

Add a new free dart to the map.

§Return

Returns the ID of the new dart.

Source

pub fn add_free_darts(&mut self, n_darts: usize) -> DartIdType

Add n_darts new free darts to the map.

§Return

Returns the ID of the first new dart. Other IDs are in the range ID..ID+n_darts.

Source

pub fn insert_free_dart(&mut self) -> DartIdType

Insert a new free dart into the map.

This method attempts to reuse an unused dart slot if available; otherwise, it adds a new one.

§Return

Returns the ID of the inserted dart.

Source

pub fn remove_free_dart(&mut self, dart_id: DartIdType)

Remove a free dart from the map.

The removed dart identifier is added to the list of free darts. This way of proceeding is necessary as the structure relies on dart indexing for encoding data, making reordering of any sort extremely costly.

§Arguments
  • dart_id: DartIdType – Identifier of the dart to remove.
§Panics

This method may panic if:

  • the dart is not free for all i,
  • the dart is already marked as unused.
Source§

impl<T: CoordsFloat> CMap3<T>

Beta-related methods

Source

pub fn beta_transac<const I: u8>( &self, trans: &mut Transaction, dart_id: DartIdType, ) -> StmClosureResult<DartIdType>

Return βI(dart_id).

§Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

§Panics

The method will panic if I is not 0, 1, 2, or 3.

Source

pub fn beta_rt_transac( &self, trans: &mut Transaction, i: u8, dart_id: DartIdType, ) -> StmClosureResult<DartIdType>

Return βi(dart_id).

§Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

§Panics

The method will panic if i is not 0, 1, 2, or 3.

Source

pub fn beta<const I: u8>(&self, dart_id: DartIdType) -> DartIdType

Return βI(dart_id).

§Panics

The method will panic if I is not 0, 1, 2, or 3.

Source

pub fn beta_rt(&self, i: u8, dart_id: DartIdType) -> DartIdType

Return βi(dart_id).

§Panics

The method will panic if i is not 0, 1, 2, or 3.

Source

pub fn is_i_free<const I: u8>(&self, dart_id: DartIdType) -> bool

Check if a given dart is I-free.

§Return

The method returns:

  • true if βI(dart_id) = NULL_DART_ID,
  • false otherwise.
§Panics

The function will panic if I is not 0, 1, 2, or 3.

Source

pub fn is_free(&self, dart_id: DartIdType) -> bool

Check if a given dart is free for all i.

§Return

Returns true if the dart is 0-free, 1-free, 2-free, and 3-free.

Source§

impl<T: CoordsFloat> CMap3<T>

I-cell-related methods

Source

pub fn vertex_id(&self, dart_id: DartIdType) -> VertexIdType

Compute the ID of the vertex a given dart is part of.

This corresponds to the minimum dart ID among darts composing the 0-cell orbit.

Source

pub fn vertex_id_transac( &self, trans: &mut Transaction, dart_id: DartIdType, ) -> Result<VertexIdType, StmError>

Compute the ID of the vertex a given dart is part of, transactionally.

This corresponds to the minimum dart ID among darts composing the 0-cell orbit.

§Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

Source

pub fn edge_id(&self, dart_id: DartIdType) -> EdgeIdType

Compute the ID of the edge a given dart is part of.

This corresponds to the minimum dart ID among darts composing the 1-cell orbit.

Source

pub fn edge_id_transac( &self, trans: &mut Transaction, dart_id: DartIdType, ) -> Result<EdgeIdType, StmError>

Compute the ID of the edge a given dart is part of.

This corresponds to the minimum dart ID among darts composing the 1-cell orbit.

§Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

Source

pub fn face_id(&self, dart_id: DartIdType) -> FaceIdType

Compute the ID of the face a given dart is part of.

This corresponds to the minimum dart ID among darts composing the 2-cell orbit.

Source

pub fn face_id_transac( &self, trans: &mut Transaction, dart_id: DartIdType, ) -> Result<FaceIdType, StmError>

Compute the ID of the face a given dart is part of.

This corresponds to the minimum dart ID among darts composing the 2-cell orbit.

§Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

Source

pub fn volume_id(&self, dart_id: DartIdType) -> VolumeIdType

Compute the ID of the volume a given dart is part of.

This corresponds to the minimum dart ID among darts composing the 3-cell orbit.

Source

pub fn volume_id_transac( &self, trans: &mut Transaction, dart_id: DartIdType, ) -> Result<VolumeIdType, StmError>

Compute the ID of the volume a given dart is part of.

This corresponds to the minimum dart ID among darts composing the 3-cell orbit.

§Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

Source

pub fn i_cell<const I: u8>(&self, dart_id: DartIdType) -> Orbit3<'_, T>

Return the orbit defined by a dart and its I-cell.

§Usage

The Orbit3 can be iterated upon to retrieve all dart members of the cell. Note that the dart passed as an argument is included as the first element of the returned orbit.

§Panics

The method will panic if I is not 0, 1, 2, or 3.

Source

pub fn iter_vertices(&self) -> impl Iterator<Item = VertexIdType> + '_

Return an iterator over IDs of all the map’s vertices.

Source

pub fn iter_edges(&self) -> impl Iterator<Item = EdgeIdType> + '_

Return an iterator over IDs of all the map’s edges.

Source

pub fn iter_faces(&self) -> impl Iterator<Item = FaceIdType> + '_

Return an iterator over IDs of all the map’s faces.

Source

pub fn iter_volumes(&self) -> impl Iterator<Item = VolumeIdType> + '_

Return an iterator over IDs of all the map’s volumes.

Source§

impl<T: CoordsFloat> CMap3<T>

Source

pub fn n_vertices(&self) -> usize

Return the current number of vertices.

Source

pub fn read_vertex( &self, trans: &mut Transaction, vertex_id: VertexIdType, ) -> StmClosureResult<Option<Vertex3<T>>>

Return the vertex associated to a given identifier.

§Return / Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

This method return a Option taking the following values:

  • Some(v: Vertex3) if there is a vertex associated to this ID,
  • None otherwise.
§Panics

The method may panic if:

  • the index lands out of bounds,
  • the index cannot be converted to usize.
Source

pub fn write_vertex( &self, trans: &mut Transaction, vertex_id: VertexIdType, vertex: impl Into<Vertex3<T>>, ) -> StmClosureResult<Option<Vertex3<T>>>

Replace the vertex associated to a given identifier and return its old value.

§Arguments
  • vertex_id: VertexIdentifier – Identifier of the vertex to replace.
  • vertex: impl Into<Vertex3> – New Vertex3 value.
§Return / Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

The result contains an Option taking the following values:

  • Some(v: Vertex3) if there was an old value,
  • None otherwise.
§Panics

The method may panic if:

  • the index lands out of bounds,
  • the index cannot be converted to usize.
Source

pub fn remove_vertex( &self, trans: &mut Transaction, vertex_id: VertexIdType, ) -> StmClosureResult<Option<Vertex3<T>>>

Remove the vertex associated to a given identifier and return it.

§Return / Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

The result contains an Option taking the following values:

  • Some(v: Vertex3) if there was a value,
  • None otherwise.
§Panics

The method may panic if:

  • the index lands out of bounds,
  • the index cannot be converted to usize.
Source

pub fn force_read_vertex(&self, vertex_id: VertexIdType) -> Option<Vertex3<T>>

Read the vertex associated to a given identifier.

This variant is equivalent to read_vertex, but internally uses a transaction that will be retried until validated.

Source

pub fn force_write_vertex( &self, vertex_id: VertexIdType, vertex: impl Into<Vertex3<T>>, ) -> Option<Vertex3<T>>

Write a vertex to a given identifier, and return its old value.

This variant is equivalent to write_vertex, but internally uses a transaction that will be retried until validated.

Source

pub fn force_remove_vertex(&self, vertex_id: VertexIdType) -> Option<Vertex3<T>>

Remove the vertex associated to a given identifier and return it.

This variant is equivalent to remove_vertex, but internally uses a transaction that will be retried until validated.

Source§

impl<T: CoordsFloat> CMap3<T>

Source

pub fn read_attribute<A: AttributeBind + AttributeUpdate>( &self, trans: &mut Transaction, id: A::IdentifierType, ) -> StmClosureResult<Option<A>>

Return the attribute A value associated to a given identifier.

The kind of cell A binds to is automatically deduced using its AttributeBind implementation.

§Return / Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

This method return a Option taking the following values:

  • Some(a: A) if there is a value associated to this ID,
  • None otherwise, or if there is no storage for this kind of attribute in the map.
§Panics

The method may panic if:

  • the index lands out of bounds,
  • the index cannot be converted to usize.
Source

pub fn write_attribute<A: AttributeBind + AttributeUpdate>( &self, trans: &mut Transaction, id: A::IdentifierType, val: A, ) -> StmClosureResult<Option<A>>

Replace the attribute A value associated to a given identifier and return its old value.

§Arguments
  • id: A::IdentifierType – Identifier of the cell’s value to replace.
  • val: A – Attribute value.
§Return / Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

The result contains an Option taking the following values:

  • Some(a: A) if there was an old value,
  • None otherwise, or if there is no storage for this kind of attribute in the map.
§Panics

The method may panic if:

  • the index lands out of bounds,
  • the index cannot be converted to usize.
Source

pub fn remove_attribute<A: AttributeBind + AttributeUpdate>( &self, trans: &mut Transaction, id: A::IdentifierType, ) -> StmClosureResult<Option<A>>

Remove the attribute A value associated to a given identifier and return it.

§Return / Errors

This method is meant to be called in a context where the returned Result is used to validate the transaction passed as argument. Errors should not be processed manually, only processed via the ? operator.

The result contains an Option taking the following values:

  • Some(a: A) if there was a value,
  • None otherwise, or if there is no storage for this kind of attribute in the map.
§Panics

The method may panic if:

  • the index lands out of bounds,
  • the index cannot be converted to usize.
Source

pub fn force_read_attribute<A: AttributeBind + AttributeUpdate>( &self, id: A::IdentifierType, ) -> Option<A>

Return the attribute A value associated to a given identifier.

This variant is equivalent to read_attribute, but internally uses a transaction that will be retried until validated.

Source

pub fn force_write_attribute<A: AttributeBind + AttributeUpdate>( &self, id: A::IdentifierType, val: A, ) -> Option<A>

Replace the attribute A value associated to a given identifier and return its old value.

This variant is equivalent to write_attribute, but internally uses a transaction that will be retried until validated.

Source

pub fn force_remove_attribute<A: AttributeBind + AttributeUpdate>( &self, id: A::IdentifierType, ) -> Option<A>

Remove the attribute A value associated to a given identifier and return it.

This variant is equivalent to remove_attribute, but internally uses a transaction that will be retried until validated.

Source

pub fn remove_attribute_storage<A: AttributeBind + AttributeUpdate>(&mut self)

Remove the attribute A’s storage from the map.

This method is useful when implementing routines that use attributes to run; Those can then be removed before the final result is returned.

Source§

impl<T: CoordsFloat> CMap3<T>

I-link operator.

§Description

This operation corresponds to coherently linking two darts via their β images. Unlike sewing, this does not alter associated attributes. For a thorough explanation of this operation, its hypothesis & consequences, refer to the user guide.

§Arguments
  • const I: u8 – Link dimension.
  • trans: &mut Transaction – Transaction associated to the operation.
  • lhs_dart_id: DartIdType – First dart ID.
  • rhs_dart_id: DartIdType – Second dart ID.
§Errors

This method should be called in a transactional context. The Result is then used to validate the transaction; Errors should not be processed manually, only processed via the ? operator. The policy in case of failure can be defined when creating the transaction, using Transaction::with_control.

§Panics

The method may panic if:

  • I >= 4 or I == 0,
  • the two darts are not I-linkable.

I-unlink operator.

§Description

This operation corresponds to unlinking two darts by resetting their β images. Unlike unsewing, this does not alter associated attributes. For a thorough explanation of this operation, its hypothesis & consequences, refer to the user guide.

§Arguments
  • const I: u8 – Unlink dimension.
  • trans: &mut Transaction – Transaction associated to the operation.
  • lhs_dart_id: DartIdType – First dart ID.

The second dart ID is fetched using I and lhs_dart_id.

§Errors

This method should be called in a transactional context. The Result is then used to validate the transaction; Errors should not be processed manually, only processed via the ? operator. The policy in case of failure can be defined when creating the transaction, using Transaction::with_control.

§Panics

The method may panic if:

  • I >= 4 or I == 0,
  • lhs_dart_id is already I-free.

I-link operator.

This variant is equivalent to link, but internally uses a transaction that will be retried until validated.

I-unlink operator.

This variant is equivalent to unlink, but internally uses a transaction that will be retried until validated.

Source§

impl<T: CoordsFloat> CMap3<T>

Serialization methods

Source

pub fn serialize(&self, writer: impl Write)

Serialize the map under a custom format.

The format specification is described in the user guide.

Source§

impl<T: CoordsFloat> CMap3<T>

§Sew operations

Source

pub fn sew<const I: u8>( &self, trans: &mut Transaction, ld: DartIdType, rd: DartIdType, ) -> TransactionClosureResult<(), SewError>

I-sew operator.

§Description

This operation corresponds to:

  • coherently linking two darts via their β images,
  • merging the attributes associated to their respective original I-cells.

For a thorough explanation of this operation, its hypothesis & consequences, refer to the user guide.

§Arguments
  • const I: u8 – Sew dimension.
  • trans: &mut Transaction – Transaction associated to the operation.
  • ld: DartIdType – First dart ID.
  • rd: DartIdType – Second dart ID.
§Errors

This variant will abort the sew operation and raise an error if:

  • the transaction cannot be completed,
  • one (or more) attribute merge fails,
  • for I == 3: orientation is inconsistent.

The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose to retry or abort as he wishes using Transaction::with_control.

§Panics

The method may panic if:

  • I >= 4 or I == 0,
  • the two darts are not I-sewable.
Source

pub fn unsew<const I: u8>( &self, trans: &mut Transaction, ld: DartIdType, ) -> TransactionClosureResult<(), SewError>

I-unsew operator.

§Description

This operation corresponds to:

  • unlinking two darts by resetting their β images,
  • splitting the attributes associated to the original I-cell.

For a thorough explanation of this operation, its hypothesis & consequences, refer to the user guide.

§Arguments
  • const I: u8 – Unsew dimension.
  • trans: &mut Transaction – Transaction associated to the operation.
  • ld: DartIdType – First dart ID.

The second dart ID is fetched using I and ld.

§Errors

This variant will abort the unsew operation and raise an error if:

  • the transaction cannot be completed,
  • one (or more) attribute split fails.

The returned error can be used in conjunction with transaction control to avoid any modifications in case of failure at attribute level. The user can then choose to retry or abort as he wishes using Transaction::with_control.

§Panics

The method may panic if:

  • I >= 4 or I == 0,
  • ld is already I-free.
Source

pub fn force_sew<const I: u8>( &self, ld: DartIdType, rd: DartIdType, ) -> Result<(), SewError>

I-sew operator.

This variant is equivalent to sew, but internally uses a transaction that will be retried until validated.

Source

pub fn force_unsew<const I: u8>(&self, ld: DartIdType) -> Result<(), SewError>

I-unsew operator.

This variant is equivalent to unsew, but internally uses a transaction that will be retried until validated.

Source§

impl<T: CoordsFloat> CMap3<T>

Utilities

Source

pub fn set_beta<const I: u8>(&self, dart_id: DartIdType, val: DartIdType)

Set the value of the specified beta function of a dart.

§Arguments
  • const I: u8 – Beta function to edit.
  • dart_id: DartIdType – ID of the dart of interest.
  • val: DartIdType – New value of βI(dart_id).
Source

pub fn set_betas(&self, dart_id: DartIdType, [b0, b1, b2, b3]: [DartIdType; 4])

Set the values of the beta functions of a dart.

§Arguments
  • dart_id: DartIdType – ID of the dart of interest.
  • betas: [DartIdType; 4] – New values of 0(dart), β1(dart), β2(dart), β3(dart)]

Trait Implementations§

Auto Trait Implementations§

§

impl<T> Freeze for CMap3<T>

§

impl<T> !RefUnwindSafe for CMap3<T>

§

impl<T> Unpin for CMap3<T>
where T: Unpin,

§

impl<T> !UnwindSafe for CMap3<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.