GH_Structure<T>

References
Represents a data tree where each branch has a unique path
TThe data type that this structure maintains. Must implement IGH_Goo or derive from a class that implements IGH_Goo. where IGH_Goo

Constructors

GH_Structure

#
Default constructor, create a blank data structure.
public GH_Structure()

GH_Structure

#
Copy constructor, duplicate another data structure.
public GH_Structure(
GH_Structure<T>
other,
Structure to copy, if null, this structure will be empty.
shallowCopy
If True, data item pointers are shared among this and the [other] structure.
)

Properties

Branch

#
Gets a limited access pointer to the data list associated with a certain path.
public IList Branch[GH_Path path] { get; }
path (GH_Path)Data path to retrieve.
Branch

Branch

#
Gets a limited access pointer to the data list at the specified index
public IList Branch[int index] { get; }
index (int)Index of data to retrieve.
Branch

Branches

#
Gets a list of all the data-arrays in this structure
public IList<List<T>> Branches { get; }

DataCount

#
Gets the total number of data items stored in all paths.
public int DataCount { get; }
DataCount

DataItem

#
Gets a direct pointer to a data item under a specific path and index.
public T DataItem[GH_Path path, int index] { get; }
path (GH_Path)Path of the data branch to retrieve.
index (int)Index of item to retrieve.
NullReferenceExceptionThrown if the path doesn't exist.
IndexOutOfRangeExceptionThrown if the index does not exist within the path list.

DataItem

#
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 T DataItem[int index] { get; }
index (int)Offset of item to retrieve
IndexOutOfRangeExceptionThrown if index is smaller than zero or larger than the size of the collection

FirstItem

#
Gets the first item in the structure. If no such item exists, null is returned.
public T FirstItem[bool filter_nulls] { get; }
filter_nulls (bool)If True, nulls will be skipped.

IsEmpty

#
Gets the Empty state of the structure. If the structure is Empty it contains no paths and no branches.
public bool IsEmpty { get; }
IsEmpty

LastItem

#
Gets the last item in the structure. If no such item exists, null is returned.
public T LastItem[bool filter_nulls] { get; }
filter_nulls (bool)If True, nulls will be skipped.

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 IEnumerable<T> NonNulls { get; }

Path

#
Gets the data path at the specified index.
public GH_Path Path[int index] { get; }
index (int)Index of path to retrieve.
IndexOutOfRangeExceptionThrown if the index does not represent a valid path.
Path

PathCount

#
Gets the number of paths defined in this structure.
public int PathCount { get; }
PathCount

Paths

#
Gets a list of all the paths in this structure.
public IList<GH_Path> Paths { get; }
Paths

StructureProxy

#
Gets a proxy list of all the data-arrays in this structure.
public IList<IList> StructureProxy { get; }
StructureProxy

TopologyDescription

#
Gets a description of the topology of the structure. Useful for debugging purposes.
public string TopologyDescription { get; }

Indexers

DataList

#
Gets a direct pointer to the list of data under a specific path.
public List<T> this[
path
Path of the data branch to retrieve. If the path doesn't exist, null is returned.
] { get; }

DataList

#
Gets a direct pointer to the list of data under the specified index.
public List<T> this[
index
Index of the data branch to retrieve.
] { get; }
IndexOutOfRangeExceptionThrown if the index does not represent a valid branch.

Methods

AllData

#
Gets an enumerator for all the data items in this structure.
public IGH_StructureEnumerator AllData(
skipNulls
If True, null items will be skipped.
)
AllData

Append

#
Append a data item to the specified branch in the structure. If the branch doesn't exist yet, it will be created.
public void Append(
T
data,
Data to append
path
Data path
)

Append

#
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 void Append(
T
data
Data to append.
)

AppendRange

#
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 void AppendRange(
data,
Data to append
path
Data path
)

AppendRange

#
Append a list of data items to the last branch in the structure
public void AppendRange(
data
Data to append
)

Clear

#
Clears the entire structure.
public void Clear()
Clear

ClearData

#
Removes all data from all paths without affecting the structure topology.
public void ClearData()
ClearData

DataDescription

#
Gets a description of the data contained in this structure.
public string DataDescription(
includeIndices,
If true, every data item will be prefixed by its index.
includePaths
If true, every branch of data will be preceded by the path.
)
A string describing the data.
DataDescription

Duplicate

#
Create an exact duplicate of this structure. All data items are copied as well.
public GH_Structure<T> Duplicate()

DuplicateCast<Q>

#
Create a duplicate of this structure in a different type.
public GH_Structure<Q> DuplicateCast<Q>(
conversion
Conversion delegate.
)
A duplicate of this structure with all valid casts.

EnsureCapacity

#
Ensures that all current branches have a certain capacity.
public void EnsureCapacity(
capacity
Capacity per branch.
)
EnsureCapacity

EnsurePath

#
Create a new branch with the specified path if it doesn't already exists.
public List<T> EnsurePath(
path
Path of the branch to ensure.
)
The list that belongs to the specified path.

EnsurePath

#
Create a new branch with the specified path if it doesn't already exists.
public List<T> EnsurePath(
params int[]
path
Path of the branch to ensure.
)
The list that belongs to the specified path.

ExpandPath

#
Expand a path in this structure by appending an element.
public void ExpandPath(
path,
Path to expand, if the path doesn't exist, nothing will happen.
element,
Element to append to the path.
mode
Expansion mode.
)
ExpandPath

Flatten

#
Flattens the entire structure into a single path.
public void Flatten(
flat_path = null
The path of the flattened data. If null, the path will be {0}
)
Flatten

FlattenData

#
Collects all data in the structure under a single list. Does not alter the state of this structure.
public List<T> FlattenData()
A linear list containing all data items in all branches.

GetEnumerator

#
public IEnumerator GetEnumerator()

GetEnumerator_Generic

#
public IEnumerator<T> GetEnumerator_Generic()

Graft

#
Grafts all paths by reallocating all data into child paths.
[EditorBrowsable(EditorBrowsableState.Never)] public void Graft(
clearSingleNulls
If True, nulls will not be grafted.
)
obsoletethis method has been replaced by Graft(GH_GraftMode)
Graft

Graft

#
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 void Graft(
mode,
Graft mode.
path
Path to graft
)
Graft

Graft

#
Grafts all paths by reallocating all data into child paths.
public void Graft(
mode
Graft mode.
)
Graft

Graft

#
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.
[EditorBrowsable(EditorBrowsableState.Never)] public void Graft(
path,
Path of data to graft.
clearSingleNulls
If true, nulls will not be grafted.
)
obsoletethis method has been replaced by Graft(GH_GraftMode, GH_Path)
Graft

Insert

#
Insert a data item into the specified branch in the structure. If the branch doesn't exist yet, it will be created.
public void Insert(
T
data,
Data to insert.
path,
Path of branch to insert into.
index
Insertion index.
)

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 int LongestPathIndex()
The index of the longest path or -1 if there are no paths.
LongestPathIndex

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 void MergeStructure(
other
Structure to merge
)

PathExists

#
Returns True if the specified path is already defined inside the structure.
public bool PathExists(
path
The data path to search for
)
PathExists

PathIndex

#
Find the indices that surround the given path domain. Indices may be out of bounds.
public void PathIndex(
path,
Path to search for (it need not exist in the structure).
ref int
idx0,
The index of the path itself or the first smaller path if the path is not defined.
ref int
idx1
The index of th path itself of the first larger path if the path is not defined.
)
PathIndex

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 bool Read(
reader
Archive to read from.
)
True on success, false on failure.
Read

RemoveData

#
Removes the first occurence of a data instance in the tree.
public void RemoveData(
T
data
Data to remove.
)

RemovePath

#
Removes a path and all associated data from the structure. If the path doesn't exist, nothing will happen.
public void RemovePath(
path
Path to remove.
)
RemovePath

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 void ReplacePath(
find,
The path to search for.
replace
The new path.
)
ReplacePath

Reverse

#
Reverse the order of items in all branches.
public void Reverse()

ShallowDuplicate

#
Create a structure with a similar topology to this one with pointers to the same data items.
public GH_Structure<T> ShallowDuplicate()

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 int ShortestPathIndex()
The index of the shortest path or -1 if there are no paths.
ShortestPathIndex

Simplify

#
Simplify the data structure by collapsing path indices shared by all branches.
public void Simplify(
mode
Simplification algorithm to use.
)
Simplify

ToString

#
public override string ToString()
Object.ToString

TrimExcess

#
Trims the excess allocated memory in all branches.
public void TrimExcess()
TrimExcess

Write

#
Write the entire GH_Structure to an archive. This method relies on the the serialization of the IGH_Goo items it contains.
public bool Write(
writer
Archive to write to.
)
True on success, false on failure.
Write