pub struct ShapeTree { /* private fields */ }
Expand description

The ShapeTree struct contains a vector of ShapeTreeItem objects.

Properties:

  • shapes: shapes is a vector of ShapeTreeItem structs that represents the collection of shapes in the ShapeTree. Each ShapeTreeItem struct contains information about a single shape, such as its type, position, and size.

Implementations§

source§

impl ShapeTree

source

pub fn new(shape: Shape) -> Self

The approach to the problem is using Reverse Level Order Traversal and storing all the levels in a 2D vector having each of the levels stored in a different row. The steps to follow are described below:

  1. Create a vector nodes to store the nodes to be evaluated.
  2. Create the shapes vector to store the different levels.
  3. Push the root node, provided node, into the queue.
  4. Iterate over the nodes until there’s no value left: 4.1 Iterate over all the nodes that were there at the beginning of the iteration. 4.2 Take the first node in the queue and match it against its Enum 4.2.1 If it is a TripleConstraint => push it to the temporary vector for the current iteration 4.2.2 If it is a ShapeReference => push it to the temporary vector and enqueue its child 4.2.3 If it is a ShapeComposite => push it to the temporary vector and enqueue its children 4.2.4 If it is a ShapeLiteral => push it to the temporary vector for the current iteration 4.2.5 If it is a NumericFacet => push it to the temporary vector and enqueue its child 4.3 Push the temporary results into the shapes vector 4.4 Clear the temporary results.
  5. Return the shapes vector in reverse order
source

pub fn iterations(&self) -> u8

The function returns the number of iterations needed to generate all possible combinations of shapes in a given object. This is a Theorem than can be seen in further detail in the paper associated with this project.

Returns:

The function iterations returns a u8 value which represents the number of iterations required to generate all possible combinations of shapes in the self object. If the self object contains an n-ary shape, then the number of iterations is equal to the number of shapes minus one, otherwise it is equal to the number of shapes.

Trait Implementations§

source§

impl Clone for ShapeTree

source§

fn clone(&self) -> ShapeTree

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl IntoIterator for ShapeTree

§

type Item = Vec<Shape, Global>

The type of the elements being iterated over.
§

type IntoIter = IntoIter<<ShapeTree as IntoIterator>::Item, Global>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Allocation for Twhere T: RefUnwindSafe + Send + Sync,