GH_Structure.T.
Represents a data tree where each branch has a unique path
Inheritance Hierarchy
System.Object
Grasshopper.Kernel.Data.GH_Structure.T.
Namespace: Grasshopper.Kernel.Data
Assembly: Grasshopper (in Grasshopper.dll)
Syntax
public class GH_Structure<T> : IGH_Structure, IEnumerable<T>, GH_ISerializablewhere T : IGH_Goo
T
The data type that this structure maintains. Must implement IGH_Goo or derive from a class that implements IGH_Goo.
The GH_Structure.T. type exposes the following members.
Constructors
Name
Description
Public Method
GH_Structure.T..
Default constructor, create a blank data structure.
Public Method
GH_Structure.T.(GH_Structure.T., Boolean)
Copy constructor, duplicate another data structure.
Properties
Name
Description
Public Property
Branch.GH_Path.
Gets a limited access pointer to the data list associated with a certain path.
Public Property
Branch.Int32.
Gets a limited access pointer to the data list at the specified index
Public Property
Branches
Gets a list of all the data-arrays in this structure
Public Property
DataCount
Gets the total number of data items stored in all paths.
Public Property
DataItem.Int32.
Gets the item at a given offset. The structure is treated as a linear list in this case. If index is out of range, null is returned. For repeated indexed retrieval, consider using a For Each loop since the enumerator is more efficient.
Public Property
DataItem.GH_Path, Int32.
Gets a direct pointer to a data item under a specific path and index.
Public Property
DataList.GH_Path.
Gets a direct pointer to the list of data under a specific path.
Public Property
DataList.Int32.
Gets a direct pointer to the list of data under the specified index.
Public Property
FirstItem
Gets the first item in the structure. If no such item exists, null is returned.
Public Property
IsEmpty
Gets the Empty state of the structure. If the structure is Empty it contains no paths and no branches.
Public Property
LastItem
Gets the last item in the structure. If no such item exists, null is returned.
Public Property
NonNulls
Get an enumerator for this structure that allow linear iteration over the data hierarchy while skipping all Null entries. This Enumerator has been optimized, do not cache instances of it.
Public Property
Path
Gets the data path at the specified index.
Public Property
PathCount
Gets the number of paths defined in this structure.
Public Property
Paths
Gets a list of all the paths in this structure.
Public Property
StructureProxy
Gets a proxy list of all the data-arrays in this structure.
Public Property
TopologyDescription
Gets a description of the topology of the structure. Useful for debugging purposes.
Methods
Name
Description
Public Method
AllData
Gets an enumerator for all the data items in this structure.
Public Method
Append(T)
Append a data item to the last branch in the structure. If no branch exist yet, a new one will be created with [path = {0}]
Public Method
Append(T, GH_Path)
Append a data item to the specified branch in the structure. If the branch doesn’t exist yet, it will be created.
Public Method
AppendRange(IEnumerable.T.)
Append a list of data items to the last branch in the structure
Public Method
AppendRange(IEnumerable.T., GH_Path)
Append a list of data items to the specified branch in the structure. If the branch doesn’t exist yet, it will be created.
Public Method
Clear
Clears the entire structure.
Public Method
ClearData
Removes all data from all paths without affecting the structure topology.
Public Method
DataDescription
Gets a description of the data contained in this structure.
Public Method
Duplicate
Create an exact duplicate of this structure. All data items are copied as well.
Public Method
DuplicateCast.Q.
Create a duplicate of this structure in a different type.
Public Method
EnsureCapacity
Ensures that all current branches have a certain capacity.
Public Method
EnsurePath(GH_Path)
Create a new branch with the specified path if it doesn’t already exists.
Public Method
EnsurePath(.Int32.)
Create a new branch with the specified path if it doesn’t already exists.
Public Method
ExpandPath
Expand a path in this structure by appending an element.
Public Method
Flatten
Flattens the entire structure into a single path.
Public Method
FlattenData
Collects all data in the structure under a single list. Does not alter the state of this structure.
Public Method
GetEnumerator
Public Method
GetEnumerator_Generic
Public Method
Graft(GH_GraftMode)
Grafts all paths by reallocating all data into child paths.
Public Method
Graft(GH_GraftMode, GH_Path)
Grafts a specific path by reallocating all data into child paths. If a grafted path coincides with an existing path, the data item in question will be appended to the existing path.
Public Method
Insert
Insert a data item into the specified branch in the structure. If the branch doesn’t exist yet, it will be created.
Public Method
LongestPathIndex
Finds the path in this structure with the most dimensions. In case of multiple equally long longest paths, the last one will be returned.
Public Method
MergeStructure
Merges two structures together. Data inside similar paths will be merged into single lists and unique paths will be appended. The other structure will not be altered, so beware that data is now shared among both structures.
Public Method
PathExists
Returns True if the specified path is already defined inside the structure.
Public Method
PathIndex
Find the indices that surround the given path domain. Indices may be out of bounds.
Public Method
Read
Read the entire GH_Structure from an archive. This method relies on the the serialization of the IGH_Goo items it contains. Also, the IGH_Goo T generic must have a public constructor that takes no arguments.
Public Method
RemoveData
Removes the first occurence of a data instance in the tree.
Public Method
RemovePath
Removes a path and all associated data from the structure. If the path doesn’t exist, nothing will happen.
Public Method
ReplacePath
Replace an existing path with a different one. If the operation is successfull, then the ‘find’ path will be deleted. If the ‘replace’ path is already defined, the items in ‘find’ will be appended to the existing path.
Public Method
Reverse
Reverse the order of items in all branches.
Public Method
ShallowDuplicate
Create a structure with a similar topology to this one with pointers to the same data items.
Public Method
ShortestPathIndex
Finds the path in this structure with the least dimensions. In case of multiple equally long longest paths, the first one will be returned.
Public Method
Simplify
Simplify the data structure by collapsing path indices shared by all branches.
Public Method
ToString
(Overrides Object.ToString..)
Public Method
TrimExcess
Trims the excess allocated memory in all branches.
Public Method
Write
Write the entire GH_Structure to an archive. This method relies on the the serialization of the IGH_Goo items it contains.