|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | + |
| 4 | +using DataStructures.Common; |
| 5 | +using DataStructures.Trees; |
| 6 | + |
| 7 | +namespace DataStructures.SortedCollections |
| 8 | +{ |
| 9 | + /// <summary> |
| 10 | + /// Sorted Dictionary collection (Red-Black Tree based). |
| 11 | + /// </summary> |
| 12 | + public class SortedDictionary<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary<TKey, TValue> |
| 13 | + where TKey : IComparable<TKey> |
| 14 | + { |
| 15 | + /// <summary> |
| 16 | + /// The internal collection is a Red-Black Tree Map. |
| 17 | + /// </summary> |
| 18 | + private RedBlackTreeMap<TKey, TValue> _collection { get; set; } |
| 19 | + |
| 20 | + |
| 21 | + /// <summary> |
| 22 | + /// Constructor. |
| 23 | + /// </summary> |
| 24 | + public SortedDictionary() |
| 25 | + { |
| 26 | + _collection = new RedBlackTreeMap<TKey, TValue>(allowDuplicates: false); |
| 27 | + } |
| 28 | + |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// Gets the count of enteries in dictionary. |
| 32 | + /// </summary> |
| 33 | + public int Count |
| 34 | + { |
| 35 | + get { return _collection.Count; } |
| 36 | + } |
| 37 | + |
| 38 | + /// <summary> |
| 39 | + /// Returns true if dictionary is empty; otherwise, false. |
| 40 | + /// </summary> |
| 41 | + public bool IsEmpty |
| 42 | + { |
| 43 | + get { return Count == 0; } |
| 44 | + } |
| 45 | + |
| 46 | + public bool IsReadOnly |
| 47 | + { |
| 48 | + get { return false; } |
| 49 | + } |
| 50 | + |
| 51 | + /// <summary> |
| 52 | + /// Determines whether the current dictionary contains an entry with the specified key. |
| 53 | + /// </summary> |
| 54 | + public bool ContainsKey(TKey key) |
| 55 | + { |
| 56 | + throw new NotImplementedException(); |
| 57 | + } |
| 58 | + |
| 59 | + public bool Contains(KeyValuePair<TKey, TValue> item) |
| 60 | + { |
| 61 | + throw new NotImplementedException(); |
| 62 | + } |
| 63 | + |
| 64 | + public void Add(TKey key, TValue value) |
| 65 | + { |
| 66 | + throw new NotImplementedException(); |
| 67 | + } |
| 68 | + |
| 69 | + public bool Remove(TKey key) |
| 70 | + { |
| 71 | + throw new NotImplementedException(); |
| 72 | + } |
| 73 | + |
| 74 | + public bool TryGetValue(TKey key, out TValue value) |
| 75 | + { |
| 76 | + throw new NotImplementedException(); |
| 77 | + } |
| 78 | + |
| 79 | + public TValue this[TKey index] |
| 80 | + { |
| 81 | + get |
| 82 | + { |
| 83 | + throw new NotImplementedException(); |
| 84 | + } |
| 85 | + set |
| 86 | + { |
| 87 | + throw new NotImplementedException(); |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + public ICollection<TKey> Keys |
| 92 | + { |
| 93 | + get |
| 94 | + { |
| 95 | + throw new NotImplementedException(); |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + public ICollection<TValue> Values |
| 100 | + { |
| 101 | + get |
| 102 | + { |
| 103 | + throw new NotImplementedException(); |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + public void Add(KeyValuePair<TKey, TValue> item) |
| 108 | + { |
| 109 | + throw new NotImplementedException(); |
| 110 | + } |
| 111 | + |
| 112 | + public void Clear() |
| 113 | + { |
| 114 | + _collection = new RedBlackTreeMap<TKey, TValue>(allowDuplicates: false); |
| 115 | + } |
| 116 | + |
| 117 | + public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) |
| 118 | + { |
| 119 | + throw new NotImplementedException(); |
| 120 | + } |
| 121 | + |
| 122 | + public bool Remove(KeyValuePair<TKey, TValue> item) |
| 123 | + { |
| 124 | + throw new NotImplementedException(); |
| 125 | + } |
| 126 | + |
| 127 | + |
| 128 | + #region IEnumerable implementation |
| 129 | + |
| 130 | + public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() |
| 131 | + { |
| 132 | + throw new NotImplementedException(); |
| 133 | + } |
| 134 | + |
| 135 | + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
| 136 | + { |
| 137 | + throw new NotImplementedException(); |
| 138 | + } |
| 139 | + |
| 140 | + #endregion |
| 141 | + } |
| 142 | +} |
| 143 | + |
0 commit comments