# GH_Structure<T> class

Namespace: [Grasshopper.Kernel.Data](https://developer.rhino3d.com/api/gh1/namespace/grasshopper.kernel.data.md) · Assembly: [Grasshopper](https://developer.rhino3d.com/api/gh1/assembly/grasshopper.md)

```cs
public class GH_Structure<T> : IGH_Structure, IEnumerable<T>, GH_ISerializable
```

Represents a data tree where each branch has a unique path

**Type parameters:**

- `T` (where IGH_Goo): The data type that this structure maintains. Must implement IGH_Goo or derive from a class that implements IGH_Goo.

## Constructors

- [GH_Structure<T>](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/ctor.md): (2 overloads) Default constructor, create a blank data structure.

## Properties

- [Branch](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/branch.md): (2 overloads) Gets a limited access pointer to the data list associated with a certain path.
- [Branches](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/branches.md): Gets a list of all the data-arrays in this structure
- [DataCount](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/datacount.md): Gets the total number of data items stored in all paths.
- [DataItem](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/dataitem.md): (2 overloads) Gets a direct pointer to a data item under a specific path and index.
- [FirstItem](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/firstitem.md): Gets the first item in the structure. If no such item exists, null is returned.
- [IsEmpty](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/isempty.md): Gets the Empty state of the structure. If the structure is Empty it contains no paths and no branches.
- [LastItem](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/lastitem.md): Gets the last item in the structure. If no such item exists, null is returned.
- [NonNulls](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/nonnulls.md): 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](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/path.md): Gets the data path at the specified index.
- [PathCount](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/pathcount.md): Gets the number of paths defined in this structure.
- [Paths](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/paths.md): Gets a list of all the paths in this structure.
- [StructureProxy](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/structureproxy.md): Gets a proxy list of all the data-arrays in this structure.
- [TopologyDescription](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/topologydescription.md): Gets a description of the topology of the structure. Useful for debugging purposes.

## Indexers

- [DataList](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/item.md): (2 overloads) Gets a direct pointer to the list of data under a specific path.

## Methods

- [AllData](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/alldata.md): Gets an enumerator for all the data items in this structure.
- [Append](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/append.md): (2 overloads) Append a data item to the specified branch in the structure. If the branch doesn't exist yet, it will be created.
- [AppendRange](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/appendrange.md): (2 overloads) Append a list of data items to the specified branch in the structure. If the branch doesn't exist yet, it will be created.
- [Clear](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/clear.md): Clears the entire structure.
- [ClearData](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/cleardata.md): Removes all data from all paths without affecting the structure topology.
- [DataDescription](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/datadescription.md): Gets a description of the data contained in this structure.
- [Duplicate](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/duplicate.md): Create an exact duplicate of this structure. All data items are copied as well.
- [DuplicateCast<Q>](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/duplicatecast.md): Create a duplicate of this structure in a different type.
- [EnsureCapacity](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/ensurecapacity.md): Ensures that all current branches have a certain capacity.
- [EnsurePath](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/ensurepath.md): (2 overloads) Create a new branch with the specified path if it doesn't already exists.
- [ExpandPath](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/expandpath.md): Expand a path in this structure by appending an element.
- [Flatten](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/flatten.md): Flattens the entire structure into a single path.
- [FlattenData](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/flattendata.md): Collects all data in the structure under a single list. Does not alter the state of this structure.
- [GetEnumerator](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/getenumerator.md)
- [GetEnumerator_Generic](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/getenumerator-generic.md)
- [Graft](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/graft.md): (4 overloads) Grafts all paths by reallocating all data into child paths.
- [Insert](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/insert.md): Insert a data item into the specified branch in the structure. If the branch doesn't exist yet, it will be created.
- [LongestPathIndex](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/longestpathindex.md): Finds the path in this structure with the most dimensions. In case of multiple equally long longest paths, the last one will be returned.
- [MergeStructure](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/mergestructure.md): 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.
- [PathExists](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/pathexists.md): Returns True if the specified path is already defined inside the structure.
- [PathIndex](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/pathindex.md): Find the indices that surround the given path domain. Indices may be out of bounds.
- [Read](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/read.md): 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.
- [RemoveData](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/removedata.md): Removes the first occurence of a data instance in the tree.
- [RemovePath](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/removepath.md): Removes a path and all associated data from the structure. If the path doesn't exist, nothing will happen.
- [ReplacePath](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/replacepath.md): 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.
- [Reverse](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/reverse.md): Reverse the order of items in all branches.
- [ShallowDuplicate](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/shallowduplicate.md): Create a structure with a similar topology to this one with pointers to the same data items.
- [ShortestPathIndex](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/shortestpathindex.md): Finds the path in this structure with the least dimensions. In case of multiple equally long longest paths, the first one will be returned.
- [Simplify](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/simplify.md): Simplify the data structure by collapsing path indices shared by all branches.
- [ToString](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/tostring.md)
- [TrimExcess](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/trimexcess.md): Trims the excess allocated memory in all branches.
- [Write](https://developer.rhino3d.com/api/gh1/type/grasshopper.kernel.data.gh-structure-1/write.md): Write the entire GH_Structure to an archive. This method relies on the the serialization of the IGH_Goo items it contains.
