Interface IDistributedList<T>
This interface contains methods and parameters for Distributed List.
Inherited Members
Assembly: Alachisoft.NCache.Client.dll
Syntax
public interface IDistributedList<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IDistributedDataTypes, ILockable, INotifiable
Type Parameters
Name | Description |
---|---|
T | The type of elements in the List. |
Methods
AddRange(IEnumerable<T>)
Adds the elements of the specified collection to the end of the List<T>.
Declaration
void AddRange(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | collection | The collection whose elements should be added to the end of the List<T> |
Examples
The following code sample shows how to add multiple of items to Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
// Get new products
Product[] newProducts = new Product[2];
newProducts[0] = new Product { Id = 1, Name = "Chai" };
newProducts[1] = new Product { Id = 2, Name = "Chang" };
newProducts[2] = new Product { Id = 3, Name = "Aniseed Syrup" };
list.AddRange(newProducts);
First()
Returns the first element of the List.
Declaration
T First()
Returns
Type | Description |
---|---|
T | The first element in the List. |
Examples
The following code sample shows how to get first element in Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
Product product = list.First();
GetRange(Int32, Int32)
Returns a List that will contain only the specified range of elements specified.
Declaration
IList<T> GetRange(int start, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | start | Starting index. |
System.Int32 | count | Number of items. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<T> |
Examples
The following code sample shows how to get range of specified items form Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
IList<Product> subList = list.GetRange(25, 50);
InsertAfter(T, T)
Inserts the element in the List after the first occurrence of specified element.
Declaration
bool InsertAfter(T pivot, T value)
Parameters
Type | Name | Description |
---|---|---|
T | pivot | Element after which value will be inserted. |
T | value | Element to insert in the List. |
Returns
Type | Description |
---|---|
System.Boolean | False when the value pivot was not found; else true. |
Examples
The following code sample shows how to insert a value after a given pivot in Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
// Get new products
Product[] newProducts = new Product[2];
newProducts[0] = new Product { Id = 1, Name = "Chai" };
newProducts[1] = new Product { Id = 2, Name = "Chang" };
newProducts[2] = new Product { Id = 3, Name = "Aniseed Syrup" };
list.InsertAfter(list[5], newProduct);
InsertAtHead(T)
Insert the specified value at the head of the List.
Declaration
void InsertAtHead(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | Element to insert in the List. |
Examples
The following code sample shows how to insert element at start of the Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
// Get new product
Product newProduct = FetchNewProduct();
list.InsertAtHead(newProduct);
InsertAtTail(T)
Insert the specified value at the tail of the List.
Declaration
void InsertAtTail(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | Element to insert in the List. |
Examples
The following code sample shows how to insert element at end of the Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
// Get new product
Product newProduct = FetchNewProduct();
list.InsertAtTail(newProduct);
InsertBefore(T, T)
Inserts the element in the List before the first occurrence of specified element.
Declaration
bool InsertBefore(T pivot, T value)
Parameters
Type | Name | Description |
---|---|---|
T | pivot | Element before which value will be inserted. |
T | value | Element to insert in the List. |
Returns
Type | Description |
---|---|
System.Boolean | False when the value pivot was not found; else true. |
Examples
The following code sample shows how to insert a value before a given pivot in Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
// Get new products
Product[] newProducts = new Product[2];
newProducts[0] = new Product { Id = 1, Name = "Chai" };
newProducts[1] = new Product { Id = 2, Name = "Chang" };
newProducts[2] = new Product { Id = 3, Name = "Aniseed Syrup" };
list.InsertBefore(list[5], newProduct);
Last()
Returns the last element of the List.
Declaration
T Last()
Returns
Type | Description |
---|---|
T | The last element in the List. |
Examples
The following code sample shows how to get last element in Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
Product product = list.Last();
RemoveRange(IEnumerable<T>)
Removes the elements of the specified collection from the List<T>.
Declaration
int RemoveRange(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | collection | The collection whose elements should be removed from the List<T> |
Returns
Type | Description |
---|---|
System.Int32 | The number of removed elements. |
Examples
The following code sample shows how to remove multiple of specified items from Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
// Get range of expired products to be removed
Product[] newProducts = new Product[2];
newProducts[0] = new Product { Id = 1, Name = "Chai" };
newProducts[1] = new Product { Id = 2, Name = "Chang" };
newProducts[2] = new Product { Id = 3, Name = "Aniseed Syrup" };
int itemsRemoved = list.RemoveRange(newProducts);
RemoveRange(Int32, Int32)
Removes a range of elements from the List<T>.
Declaration
void RemoveRange(int index, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based starting index of the range of elements to remove. |
System.Int32 | count | The number of elements to remove. |
Examples
The following code sample shows how to remove multiple of items from Distributed List.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
list.RemoveRange(25, 50);
Trim(Int32, Int32)
Trim an existing List so that it will contain only the specified range of elements.
Declaration
void Trim(int start, int end)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | start | Starting index. |
System.Int32 | end | Ending index. |
Examples
The following code sample shows how to trim a Distributed List from index 5 to 10.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedList";
IDistributedList<Product> list = cache.DataTypeManager.GetList<Product>(dataTypeName);
list.Trim(5, 10);