CSharpTest.Net
OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>)
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedEnumeration<T> Class > OrderedEnumeration<T> Constructor : OrderedEnumeration<T> Constructor(IComparer<T>,IEnumerable<T>)

comparer
unordered

Glossary Item Box

Constructs an ordered enumeration from an unordered enumeration

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal comparer As IComparer(Of T), _
   ByVal unordered As IEnumerable(Of T) _
)
C# 
public OrderedEnumeration<T>( 
   IComparer<T> comparer,
   IEnumerable<T> unordered
)

Parameters

comparer
unordered

Example

Library/Library.Test/TestOrderedEnumeration.cs

C#Copy Code
var ordered = new OrderedEnumeration<byte>(Comparer<byte>.Default, FailBeforeYield<byte>(true));

Assert.IsTrue(ReferenceEquals(Comparer<byte>.Default, ordered.Comparer));
ordered.Comparer = new ReverseOrder<byte>(ordered.Comparer);
Assert.IsTrue(ordered.Comparer is ReverseOrder<byte>);

Assert.IsNull(ordered.Serializer);
ordered.Serializer = PrimitiveSerializer.Byte;
Assert.IsTrue(ReferenceEquals(ordered.Serializer, PrimitiveSerializer.Byte));

Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(10, ordered.InMemoryLimit = 10);

Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(DuplicateHandling.FirstValueWins,
                ordered.DuplicateHandling = DuplicateHandling.FirstValueWins);
VB.NETCopy Code
Dim ordered As var = New OrderedEnumeration(Of Byte)(Comparer(Of Byte).[Default], FailBeforeYield(Of Byte)(True))

Assert.IsTrue(ReferenceEquals(Comparer(Of Byte).[Default], ordered.Comparer))
ordered.Comparer = New ReverseOrder(Of Byte)(ordered.Comparer)
Assert.IsTrue(TypeOf ordered.Comparer Is ReverseOrder(Of Byte))

Assert.IsNull(ordered.Serializer)
ordered.Serializer = PrimitiveSerializer.[Byte]
Assert.IsTrue(ReferenceEquals(ordered.Serializer, PrimitiveSerializer.[Byte]))

Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(10, ordered.InMemoryLimit = 10)

Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(DuplicateHandling.FirstValueWins, ordered.DuplicateHandling = DuplicateHandling.FirstValueWins)

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys