Gets an
ICollection containing the keys of the
IDictionary.
Syntax
Example
BPlusTree/BPlusTree.Test/BasicTests.cs
C# | Copy Code |
---|
List<KeyValuePair<int, string>> sample = new List<KeyValuePair<int, string>>();
for (int i = 0; i < 20; i++)
sample.Add(new KeyValuePair<int,string>(i, i.ToString()));
using (BPlusTree<int, string> data = Create(Options))
{
data.AddRange(sample);
//Key collection
Assert.AreEqual(data.Count, data.Keys.Count);
Assert.IsTrue(data.Keys.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
Assert.IsTrue(data.Keys.Contains(sample[i].Key));
IEnumerator<int> ek = data.Keys.GetEnumerator();
Assert.IsTrue(ek.MoveNext());
int firstkey = ek.Current;
Assert.IsTrue(ek.MoveNext());
Assert.AreNotEqual(firstkey, ek.Current);
ek.Reset();
Assert.IsTrue(ek.MoveNext());
Assert.AreEqual(firstkey, ek.Current);
Assert.AreEqual(firstkey, ((System.Collections.IEnumerator) ek).Current);
//Value collection
Assert.AreEqual(data.Count, data.Values.Count);
Assert.IsTrue(data.Values.IsReadOnly);
for (int i = 0; i < sample.Count && i < 5; i++)
Assert.IsTrue(data.Values.Contains(sample[i].Value));
IEnumerator<string> ev = data.Values.GetEnumerator();
Assert.IsTrue(ev.MoveNext());
string firstvalue = ev.Current;
Assert.IsTrue(ev.MoveNext());
Assert.AreNotEqual(firstvalue, ev.Current);
ev.Reset();
Assert.IsTrue(ev.MoveNext());
Assert.AreEqual(firstvalue, ((System.Collections.IEnumerator) ev).Current);
} |
VB.NET | Copy Code |
---|
Dim sample As New List(Of KeyValuePair(Of Integer, String))()
Dim i As Integer = 0
While i < 20
sample.Add(New KeyValuePair(Of Integer, String)(i, i.ToString()))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Using data As BPlusTree(Of Integer, String) = Create(Options)
data.AddRange(sample)
'Key collection
Assert.AreEqual(data.Count, data.Keys.Count)
Assert.IsTrue(data.Keys.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
Assert.IsTrue(data.Keys.Contains(sample(i).Key))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim ek As IEnumerator(Of Integer) = data.Keys.GetEnumerator()
Assert.IsTrue(ek.MoveNext())
Dim firstkey As Integer = ek.Current
Assert.IsTrue(ek.MoveNext())
Assert.AreNotEqual(firstkey, ek.Current)
ek.Reset()
Assert.IsTrue(ek.MoveNext())
Assert.AreEqual(firstkey, ek.Current)
Assert.AreEqual(firstkey, (DirectCast(ek, System.Collections.IEnumerator)).Current)
'Value collection
Assert.AreEqual(data.Count, data.Values.Count)
Assert.IsTrue(data.Values.IsReadOnly)
Dim i As Integer = 0
While i < sample.Count AndAlso i < 5
Assert.IsTrue(data.Values.Contains(sample(i).Value))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim ev As IEnumerator(Of String) = data.Values.GetEnumerator()
Assert.IsTrue(ev.MoveNext())
Dim firstvalue As String = ev.Current
Assert.IsTrue(ev.MoveNext())
Assert.AreNotEqual(firstvalue, ev.Current)
ev.Reset()
Assert.IsTrue(ev.MoveNext())
Assert.AreEqual(firstvalue, (DirectCast(ev, System.Collections.IEnumerator)).Current)
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also