Version

SparseArray Class Members

The following tables list the members exposed by SparseArray.

Public Constructors
 NameDescription
Public ConstructorSparseArray ConstructorOverloaded.   
Public Properties
 NameDescription
Public PropertyCountRetruns the number of items contained in the collection.  
Public PropertyIsSynchronizedIndicates whether this collection is synchronized. Always returns false.  
Public PropertyItemIndexer.  
Public PropertyNonNullItemsReturns a new instance of enumerable that can be used to enumerate through only the non-null items in the collection.  
Public PropertySyncRootReturns an object that can be used to synchronize thread access.  
Public Methods
 NameDescription
Public MethodAddAdds the speicifed item at the end of the collection.  
Public MethodAddRangeAdds items in the specified collection to the end of the collection.  
Public MethodClearRemoves all items from the array.  
Public MethodContainsReturns true if the specified item is contained in the collection.  
Public MethodCopyToOverloaded. Copies all the elements from this collection to the specified array starting at index.  
Public MethodExpandExpands the array to the new count. New count must be greater than or equal to the current count. This has the same logical effect as adding new count - current count number of null items at the end of the array.  
Public MethodGetEnumeratorOverloaded. Returns an instance of IEnumerator that can be used to enumerate through all the elements of this collection.  
Public MethodGetItemOverloaded. Gets the item at the specified index. If the item at the specified index is null and createItemCallback parameter is non-null, it will call CreateItem on the callback to create it and set it on the array at the specified index.  
Public MethodIndexOfRetruns the index of the specified item.  
Public MethodInsertInserts the specified item at the specified location in the array.  
Public MethodInsertRangeInserts items in the specified collection to the collection at the specified index.  
Public MethodRemoveRemoves the specified item. If the item doesn't exist in the collection, it does nothing.  
Public MethodRemoveAtRemoves an item at the specified index.  
Public MethodRemoveRangeRemoves count number of items starting at the specified index in the array.  
Public MethodReverseOverloaded. Reverses the order of items in the collection.  
Public MethodSortOverloaded. Sorts the array.  
Public MethodToArrayOverloaded. Returns a new array containing all the elements of this collection.  
Protected Methods
 NameDescription
Protected MethodDirtyScrollCountInfoDirties scroll count info for the whole collection so next time it will be re-calculated.  
Protected MethodGetItemAtScrollIndexReturns the item at the specified scroll index. This method returns null if the scroll index is out of bounds.  
Protected MethodGetItemAtVisibleIndexReturns the item at the specified visible index. This method returns null if the visible index is out of bounds.  
Protected MethodGetItemAtVisibleIndexOffsetReturns offset'th visible item from startItem. StartItem can be hidden in which case it will start from the next visible item. Offset can be 0. If the resulting visible index is out of bounds, returns null.  
Protected MethodGetOwnerDataReturns the owner data of the item. Derived class can override GetOwnerData and SetOwnerData to support owner data without having to implement ISparseArrayItem interface on the items.  
Protected MethodGetScrollCountReturns the scroll count.  
Protected MethodGetScrollIndexOfOverloaded. Gets the scroll index of the specified item.  
Protected MethodGetVisibleCountReturns the visible count.  
Protected MethodGetVisibleIndexOfReturns the visible index associted with the specified item. Item must be contained within the array. If the item is hidden, that is it's ScrollCount is 0, the this method returns -1.  
Protected MethodNotifyItemScrollCountChangedWhenever a scroll count of an item contained within this collection is changed, the collection must be notified of the change. If not notified of such a change, behavior of various scroll and visible index related methods will be undefined.  
Protected MethodOnScrollCountChangedCalled by the sparse array whenever visible count or scroll count changes or is dirtied. Default implementation does nothing. This may get called multiple times for the same change as well as may get called even when the count doesn't change but is simply dirtied.  
Protected MethodSetOwnerDataSets the owner data on item. Derived class can override GetOwnerData and SetOwnerData to support owner data without having to implement ISparseArrayItem interface on the items.  
See Also