Adds an element with the provided value to the
IList.
Syntax
Visual Basic (Declaration) | |
---|
Public Function TryAddItem( _
ByVal value As T _
) As Boolean |
Parameters
- value
- The object to use as the value of the element to add.
Exceptions
Example
Library/Library.Test/TestBTreeList.cs
C# | Copy Code |
---|
BTreeList<int> data = new BTreeList<int>(Comparer);
for (int i = 0; i < 100; i++)
Assert.IsTrue(data.TryAddItem(i));
Assert.AreEqual(50, new List<int>(data.EnumerateFrom(50)).Count);
Assert.AreEqual(25, new List<int>(data.EnumerateFrom(75)).Count);
for (int i = 0; i < 100; i++)
{
int first = -1;
foreach (int kv in data.EnumerateFrom(i))
{
first = kv;
break;
}
Assert.AreEqual(i, first);
} |
VB.NET | Copy Code |
---|
Dim data As New BTreeList(Of Integer)(Comparer)
Dim i As Integer = 0
While i < 100
Assert.IsTrue(data.TryAddItem(i))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Assert.AreEqual(50, New List(Of Integer)(data.EnumerateFrom(50)).Count)
Assert.AreEqual(25, New List(Of Integer)(data.EnumerateFrom(75)).Count)
Dim i As Integer = 0
While i < 100
Dim first As Integer = -1
For Each kv As Integer In data.EnumerateFrom(i)
first = kv
Exit For
Next
Assert.AreEqual(i, first)
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also