SolidKit.List generic

From Solid Graphics Wiki

Jump to: navigation, search
SolidKit.List generic
Namespace: SolidKit
Base type: (None)
Assembly: SolidKit.dll
Platform: .NET


The List generic is a C# generic for making one-dimensional arrays/lists. The template is defined as:

public class List< T > { ... }

The T is type of the objects in the list.


Constructors

The List template provide constructor with no parameters, copy constructor to allow initialize the list from another list, a constructor for allocating the list using initial capacity, or to initialize the list from array of T objects.

Fields

Field name Type Description
Data T-Array Array of T values. This is the actual array which holds the values of the list, not a copy of list values. The array has length equal to List capacity. The Count property of the list specifies how many of the values are actually used by the list.

The generic has no public fields.

Methods

Method name Description
Clear Removes all the items from the list and sets the list capacity to zero.
Capacity Gets the list current capacity value or sets the list capacity to specified value. Setting the capacity ensures that the internal data buffer for the list items won't be reallocated if number of items added to the list does not exceed the capacity value.
Add Adds a item to the end of the list. If the capacity of the list is not big enough to hold the new item then the capacity of the list will be doubled.
Insert Inserts list item to the specified position in the list. If the capacity of the list is not big enough to hold the new item then the capacity of the list will be doubled.
InsertSorted To use this method the items in the list must be sorted in ascending order. The InsertSorted method inserts the specified value into the list so the list remains sorted. If the capacity of the list is not big enough to hold the new item then the capacity of the list will be doubled.
SetTo Sets all current items in the list to specified value.
QuickRemoveAt Removes item at specified index. If the item is not a last item then the last list item is copied into the removed item's position, rather than shifting the rest of the items in memory. Be aware that this method does not keep the list's items order.
RemoveAt Removes the list item while keeping the list's sort order.
RemoveLast Removes last item from the list.
RemoveDuplicates To use this method the items in the list must be sorted in ascending order. The method erases all duplicate values from the list. For example in list of integer values, if the list contains values { 1, 2, 2, 4, 5, 5, 5, 7 }, then after running the method the list will contain values { 1, 2, 4, 5, 7 }.
Count Gets current number of items in the list or sets list size to specified count.
Sort Sorts the items in the list in ascending order.
Find Finds index of the first item of specified value in the list using linear search from beginning og the list. If the value is not found then the method returns -1.
Find To use this method the items in the list must be sorted in ascending order. The method returns index of an item with specified value using binary search algorithm. If the list contain more items with the same value then the method does not necessarily return index of first such value. If the value is not found then the method returns -1.
IndexOfEqualOrGreater To use this method the items in the list must be sorted in ascending order. The method finds index of item with value equal or greater than the specified value using binary-search algorithm. If the list contain more items with the same value then the method does not necessarily return index of first such value. If the list is empty the method return value is 0.
LastItem Returns value of the last list item.

See Also


   


SolidKit Library Documentation

Personal tools