#region Copyright 2012-2014 by Roger Knapp, Licensed under the Apache License, Version 2.0
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#endregion
using System.Collections.Generic;
using CSharpTest.Net.Serialization;
namespace CSharpTest.Net.Collections
{
///
/// Speicalizes the OrderedEnumeration of T to use key/value pairs with a key comparer.
///
public class OrderedKeyValuePairs : OrderedEnumeration>
{
/// Constructs an ordered set of KeyValuePair structs
public OrderedKeyValuePairs(IEnumerable> unordered)
: base(KeyValueComparer.Default, unordered)
{
}
/// Constructs an ordered set of KeyValuePair structs
public OrderedKeyValuePairs(IComparer comparer, IEnumerable> unordered)
: base(new KeyValueComparer(comparer), unordered)
{
}
/// Constructs an ordered set of KeyValuePair structs
public OrderedKeyValuePairs(IComparer comparer, IEnumerable> unordered,
ISerializer> serializer)
: base(new KeyValueComparer(comparer), unordered, serializer)
{
}
/// Constructs an ordered set of KeyValuePair structs
public OrderedKeyValuePairs(IComparer comparer, IEnumerable> unordered,
ISerializer> serializer, int memoryLimit)
: base(new KeyValueComparer(comparer), unordered, serializer, memoryLimit)
{
}
/// Constructs an ordered set of KeyValuePair structs
public OrderedKeyValuePairs(IComparer comparer, IEnumerable> unordered,
ISerializer keySerializer, ISerializer valueSerializer)
: base(
new KeyValueComparer(comparer), unordered,
new KeyValueSerializer(keySerializer, valueSerializer))
{
}
/// Constructs an ordered set of KeyValuePair structs
public OrderedKeyValuePairs(IComparer comparer, IEnumerable> unordered,
ISerializer keySerializer, ISerializer valueSerializer,
int memoryLimit)
: base(
new KeyValueComparer(comparer), unordered,
new KeyValueSerializer(keySerializer, valueSerializer), memoryLimit)
{
}
///
/// Merges n-number of ordered enumerations based on the comparer provided.
///
public static IEnumerable> Merge(IComparer comparer, params IEnumerable>[] enums)
{
return Merge(new KeyValueComparer(comparer), enums);
}
///
/// Merges n-number of ordered enumerations based on the comparer provided.
///
public static IEnumerable> Merge(IComparer comparer, DuplicateHandling duplicateHandling, params IEnumerable>[] enums)
{
KeyValueComparer kvcompare = new KeyValueComparer(comparer);
return WithDuplicateHandling(Merge(kvcompare, enums), kvcompare, duplicateHandling);
}
}
}