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

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

GH_Structure

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

Properties

Branch

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

Branch

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

Branches

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

DataCount

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

DataItem

#
public T DataItem[GH_Path path, int index] { get; }
Gets a direct pointer to a data item under a specific path and index.
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

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

FirstItem

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

IsEmpty

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

LastItem

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

NonNulls

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

Path

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

PathCount

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

Paths

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

StructureProxy

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

TopologyDescription

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

Indexers

DataList

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

DataList

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

Methods

AllData

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

Append

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

Append

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

AppendRange

#
public void AppendRange(IEnumerable<T> data, GH_Path 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.
data (IEnumerable<T>)Data to append
path (GH_Path)Data path

AppendRange

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

Clear

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

ClearData

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

DataDescription

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

Duplicate

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

DuplicateCast<Q>

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

EnsureCapacity

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

EnsurePath

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

EnsurePath

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

ExpandPath

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

Flatten

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

FlattenData

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

GetEnumerator

#
public IEnumerator GetEnumerator()

GetEnumerator_Generic

#
public IEnumerator<T> GetEnumerator_Generic()

Graft

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

Graft

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

Graft

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

Graft

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

Insert

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

LongestPathIndex

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

MergeStructure

#
public void MergeStructure(GH_Structure<T> other)
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.
other (GH_Structure<T>)Structure to merge

PathExists

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

PathIndex

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

Read

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

RemoveData

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

RemovePath

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

ReplacePath

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

Reverse

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

ShallowDuplicate

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

ShortestPathIndex

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

Simplify

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

ToString

#
public override string ToString()
Object.ToString

TrimExcess

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

Write

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