CSharpTest.Net
TryDequeue(KeyValuePair<TKey,TValue>) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class > TryDequeue Method : TryDequeue(KeyValuePair<TKey,TValue>) Method

value

Glossary Item Box

Removes the oldest entry in the collection based on the ordering supplied to the constructor.

Syntax

Visual Basic (Declaration) 
Public Overloads Function TryDequeue( _
   ByRef value As KeyValuePair(Of TKey,TValue) _
) As Boolean
C# 
public bool TryDequeue( 
   out KeyValuePair<TKey,TValue> value
)

Parameters

value

Return Value

False if no item was available

Exceptions

ExceptionDescription
System.InvalidOperationExceptionRaised if the table is unordered

Example

Library/Library.Test/TestLurchTable.cs

C#Copy Code
var test = new LurchTableTest<int, string>(LurchTableOrder.Access);
Assert.AreEqual(LurchTableOrder.Access, test.Ordering);
var sample = GetSample();
foreach (var item in sample)
    test.Add(item.Key, item.Value);

Array.Reverse(sample);
foreach (var item in sample)
    Assert.AreEqual(item.Value, test[item.Key]);

KeyValuePair<int, string> value;
foreach (var item in sample)
{
    Assert.IsTrue(test.TryDequeue(out value));
    Assert.AreEqual(item.Key, value.Key);
    Assert.AreEqual(item.Value, value.Value);
}

Assert.IsFalse(test.Peek(out value));
Assert.IsFalse(test.TryDequeue(out value));
VB.NETCopy Code
Dim test As var = New LurchTableTest(Of Integer, String)(LurchTableOrder.Access)
Assert.AreEqual(LurchTableOrder.Access, test.Ordering)
Dim sample As var = GetSample()
For Each item As var In sample
    test.Add(item.Key, item.Value)
Next

Array.Reverse(sample)
For Each item As var In sample
    Assert.AreEqual(item.Value, test(item.Key))
Next

Dim value As KeyValuePair(Of Integer, String)
For Each item As var In sample
    Assert.IsTrue(test.TryDequeue(value))
    Assert.AreEqual(item.Key, value.Key)
    Assert.AreEqual(item.Value, value.Value)
Next

Assert.IsFalse(test.Peek(value))
Assert.IsFalse(test.TryDequeue(value))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys