# CircularArray<T> class

Namespace: [Grasshopper2.Collections](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.collections.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
public class CircularArray<T> : IEnumerable<T>
```

Represents a threadsafe circular array. A circular array has a maximum length, but items can always be added to it efficiently. Once the capacity has been reached, newly added items override the oldest items.

**Type parameters:**

- `T`: Array type.

## Constructors

- [CircularArray<T>](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/ctor.md): Create a new circular array.

## Properties

- [Capacity](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/capacity.md): Gets the maximum capacity of this array.
- [Count](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/count.md): Gets the number of items stored in the array.
- [ItemsNewest](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/itemsnewest.md): Enumerate over all items, starting with the newest ones.
- [ItemsOldest](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/itemsoldest.md): Enumerate over all items, starting with the oldest ones.
- [Newest](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/newest.md): Gets the newest item added to the array. If the array contains no items, default(T) is returned.
- [Oldest](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/oldest.md): Gets the oldest item still in the array. If the array contains no items, default(T) is returned.

## Methods

- [Add](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/add.md): Add an item to the array.
- [Clear](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/clear.md): Clear all items in the array.
- [GetEnumerator](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/getenumerator.md): Enumerate over all items in the circular array.
- [IEnumerable.GetEnumerator](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/system-collections-ienumerable-getenumerator.md)
- [ToArray](https://developer.rhino3d.com/api/gh2/type/grasshopper2.collections.circulararray-1/toarray.md): Create a correctly sized, correctly ordered array representing the current state of the circular array. The items in the returned array are sorted from oldest to newest.
