Struct pschema_rs::shape::shape_tree::ShapeTree
source · pub struct ShapeTree { /* private fields */ }Expand description
The ShapeTree struct contains a vector of ShapeTreeItem objects.
Properties:
shapes:shapesis a vector ofShapeTreeItemstructs that represents the collection of shapes in theShapeTree. EachShapeTreeItemstruct contains information about a single shape, such as its type, position, and size.
Implementations§
source§impl ShapeTree
impl ShapeTree
sourcepub fn new(shape: Shape) -> Self
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:
- Create a vector
nodesto store the nodes to be evaluated. - Create the shapes
vectorto store the different levels. - Push the
rootnode, provided node, into the queue. - Iterate over the
nodesuntil 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 aTripleConstraint=> push it to the temporary vector for the current iteration 4.2.2 If it is aShapeReference=> push it to the temporary vector and enqueue its child 4.2.3 If it is aShapeComposite=> push it to the temporary vector and enqueue its children 4.2.4 If it is aShapeLiteral=> push it to the temporary vector for the current iteration 4.2.5 If it is aNumericFacet=> push it to the temporary vector and enqueue its child 4.3 Push the temporary results into theshapesvector 4.4 Clear the temporary results. - Return the
shapesvector in reverse order
sourcepub fn iterations(&self) -> u8
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.