CSharpTest.Net
OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<KeyValuePair<TKey,TValue>>,Int32)
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > OrderedKeyValuePairs<TKey,TValue> Class > OrderedKeyValuePairs<TKey,TValue> Constructor : OrderedKeyValuePairs<TKey,TValue> Constructor(IComparer<TKey>,IEnumerable<KeyValuePair<TKey,TValue>>,ISerializer<KeyValuePair<TKey,TValue>>,Int32)

comparer
unordered
serializer
memoryLimit

Glossary Item Box

Constructs an ordered set of KeyValuePair structs

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal comparer As IComparer(Of TKey), _
   ByVal unordered As IEnumerable(Of KeyValuePair(Of TKey,TValue)), _
   ByVal serializer As ISerializer(Of KeyValuePair(Of TKey,TValue)), _
   ByVal memoryLimit As Integer _
)

Parameters

comparer
unordered
serializer
memoryLimit

Example

Library/Library.Test/TestOrderedEnumeration.cs

C#Copy Code
IEnumerable<KeyValuePair<int,int>> e = new KeyValuePair<int,int>[0];
OrderedKeyValuePairs<int, int> ordered;

ordered = new OrderedKeyValuePairs<int, int>(e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(ReferenceEquals(Comparer<int>.Default, ((KeyValueComparer<int, int>)ordered.Comparer).Comparer));
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(null, ordered.Serializer);

KeyValueSerializer<int,int> ser = new KeyValueSerializer<int,int>(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, ser, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.AreEqual(ser, ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(0x10000, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);

ordered = new OrderedKeyValuePairs<int, int>(new ReverseOrder<int>(Comparer<int>.Default), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42);
Assert.IsTrue(ordered.Comparer is KeyValueComparer<int, int>);
Assert.IsTrue(((KeyValueComparer<int, int>)ordered.Comparer).Comparer is ReverseOrder<int>);
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling);
Assert.AreEqual(42, ordered.InMemoryLimit);
Assert.IsNotNull(ordered.Serializer);
VB.NETCopy Code
Dim e As IEnumerable(Of KeyValuePair(Of Integer, Integer)) = New KeyValuePair(Of Integer, Integer)(0) {}
Dim ordered As OrderedKeyValuePairs(Of Integer, Integer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(ReferenceEquals(Comparer(Of Integer).[Default], (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(Nothing, ordered.Serializer)

Dim ser As New KeyValueSerializer(Of Integer, Integer)(PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, ser, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.AreEqual(ser, ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(&H10000, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

ordered = New OrderedKeyValuePairs(Of Integer, Integer)(New ReverseOrder(Of Integer)(Comparer(Of Integer).[Default]), e, PrimitiveSerializer.Int32, PrimitiveSerializer.Int32, 42)
Assert.IsTrue(TypeOf ordered.Comparer Is KeyValueComparer(Of Integer, Integer))
Assert.IsTrue(TypeOf (DirectCast(ordered.Comparer, KeyValueComparer(Of Integer, Integer))).Comparer Is ReverseOrder(Of Integer))
Assert.AreEqual(DuplicateHandling.None, ordered.DuplicateHandling)
Assert.AreEqual(42, ordered.InMemoryLimit)
Assert.IsNotNull(ordered.Serializer)

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys