コード例 #1
0
 public SortedSet(IEnumerable <T> collection)
 {
     _comparer = Comparer <T> .Default;
     _wrapped  = new AVLTree <T, T>();
     foreach (var item in Check.NotNullArgument(collection, "collection"))
     {
         _wrapped.AddNonDuplicate(item, item);
     }
 }
コード例 #2
0
ファイル: SortedSet.cs プロジェクト: clintonmead/Theraot
 public SortedSet(IEnumerable <T> collection, IComparer <T> comparer)
 {
     Comparer = comparer ?? Comparer <T> .Default;
     _wrapped = new AVLTree <T, VoidStruct>();
     foreach (var item in collection ?? throw new ArgumentNullException(nameof(collection)))
     {
         _wrapped.AddNonDuplicate(item, default);
     }
 }
コード例 #3
0
ファイル: AVLTest.cs プロジェクト: pocketgems/Theraot
        private static void AddAndIterateNonDuplicate(int[] data)
        {
            var avl  = new AVLTree <int, int>();
            var copy = new List <int>();

            foreach (var item in data)
            {
                bool duplicate = copy.Contains(item);
                Assert.AreNotEqual(avl.AddNonDuplicate(item, item), duplicate);
                if (!duplicate)
                {
                    copy.Add(item);
                }
            }
            Assert.AreEqual(avl.Count, copy.Count);
            Array.Sort(data);
            var index = 0;

            foreach (var item in avl)
            {
                Assert.AreEqual(item.Key, copy[index]);
                index++;
            }
        }
コード例 #4
0
ファイル: SortedSet.cs プロジェクト: clintonmead/Theraot
 internal virtual bool AddExtracted(T item)
 {
     return(_wrapped.AddNonDuplicate(item, default));
 }
コード例 #5
0
ファイル: SortedSet.cs プロジェクト: LonghronShen/Theraot
 protected virtual bool AddExtracted(T item)
 {
     return(_wrapped.AddNonDuplicate(item, item));
 }
コード例 #6
0
ファイル: AVLTest.cs プロジェクト: mesheets/Theraot-CF
 private static void AddAndIterateNonDuplicate(int[] data)
 {
     var avl = new AVLTree<int, int>();
     var copy = new List<int>();
     foreach (var item in data)
     {
         bool duplicate = copy.Contains(item);
         Assert.AreNotEqual(avl.AddNonDuplicate(item, item), duplicate);
         if (!duplicate)
         {
             copy.Add(item);
         }
     }
     Assert.AreEqual(avl.Count, copy.Count);
     Array.Sort(data);
     var index = 0;
     foreach (var item in avl)
     {
         Assert.AreEqual(item.Key, copy[index]);
         index++;
     }
 }