Beispiel #1
0
        public static void TestKey()
        {
            var d = new ImmutableSortedDictionary <Key, int>(new KeyComparer(ConcurrentComparer.AsObjectComparer(ConcurrentComparer.CreateDefault <Byte[]>()), ConcurrentComparer.AsObjectComparer(ConcurrentComparer.CreateDefault <Optional <int> >()), ConcurrentComparer.AsObjectComparer(ConcurrentComparer.CreateDefault <String>())));

            d = d.Add(new Key(null, Optional <int> .Empty, "A"), 0);
            d = d.Add(new Key(null, Optional <int> .Empty, "B"), 1);
            d = d.Add(new Key(null, Optional <int> .Empty, "aA"), 2);
            d = d.Add(new Key(null, Optional <int> .Empty, "aB"), 3);
            d = d.Add(new Key(null, (Optional <int>)(1), "aA"), 4);
            d = d.Add(new Key(null, (Optional <int>)(1), "aB"), 5);
            d = d.Add(new Key(null, (Optional <int>)(2), "A"), 6);
            d = d.Add(new Key(null, (Optional <int>)(2), "B"), 7);
            d = d.Add(new Key(new Byte[] { }, (Optional <int>)(1), "A"), 8);
            d = d.Add(new Key(new Byte[] { 1 }, (Optional <int>)(1), "A"), 9);
            d = d.Add(new Key(new Byte[] { 1, 2 }, (Optional <int>)(1), "A"), 10);
            d = d.Add(new Key(new Byte[] { 1, 3 }, (Optional <int>)(1), "A"), 11);
            d = d.Add(new Key(new Byte[] { 2, 1 }, (Optional <int>)(1), "A"), 12);
            foreach (var v in d.Zip(Enumerable.Range(0, d.Count), (a, b) => new { Key = a.Key, Left = a.Value, Right = b }))
            {
                Debug.Assert(v.Left == v.Right);
            }
            Debug.Assert(d.RangeCount(new Key(null, KeyCondition.Min, KeyCondition.Min), new Key(null, KeyCondition.Max, KeyCondition.Max)) == 8);
            Debug.Assert(d.RangeCount(new Key(new Byte[] { }, KeyCondition.Min, KeyCondition.Min), new Key(new Byte[] { }, KeyCondition.Max, KeyCondition.Max)) == 1);
            Debug.Assert(d.RangeCount(new Key(new Byte[] { }, KeyCondition.Min, KeyCondition.Min), new Key(new Byte[] { 2, 1 }, KeyCondition.Max, KeyCondition.Max)) == 5);
        }
Beispiel #2
0
 public ImmutableSortedDictionary(bool IsReversed)
 {
     this.Compare = ConcurrentComparer.CreateDefault <TKey>(IsReversed);
     this.Root    = null;
 }
Beispiel #3
0
 public ImmutableSortedDictionary()
 {
     this.Compare = ConcurrentComparer.CreateDefault <TKey>();
     this.Root    = null;
 }