示例#1
0
        public void HugeDictionary_Basic()
        {
            HugeDictionary <string, int> dictionary;
            int value;

            dictionary = new HugeDictionary <string, int>(10);
            Assert.AreEqual(0, dictionary.Count);
            Assert.IsFalse(dictionary.ContainsKey("0"));
            Assert.IsFalse(dictionary.ContainsKey("1"));

            Assert.IsFalse(dictionary.TryGetValue("0", out value));
            Assert.AreEqual(0, value);
            Assert.IsFalse(dictionary.TryGetValue("1", out value));
            Assert.AreEqual(0, value);

            dictionary.Add("0", 0);
            Assert.AreEqual(1, dictionary.Count);
            Assert.AreEqual(0, dictionary["0"]);
            Assert.IsTrue(dictionary.ContainsKey("0"));
            Assert.IsFalse(dictionary.ContainsKey("1"));

            Assert.IsTrue(dictionary.TryGetValue("0", out value));
            Assert.AreEqual(0, value);
            Assert.IsFalse(dictionary.TryGetValue("1", out value));
            Assert.AreEqual(0, value);

            dictionary.Add("1", 1);
            Assert.AreEqual(2, dictionary.Count);
            Assert.AreEqual(0, dictionary["0"]);
            Assert.AreEqual(1, dictionary["1"]);
            Assert.IsTrue(dictionary.ContainsKey("0"));
            Assert.IsTrue(dictionary.ContainsKey("1"));

            Assert.IsTrue(dictionary.TryGetValue("0", out value));
            Assert.AreEqual(0, value);
            Assert.IsTrue(dictionary.TryGetValue("1", out value));
            Assert.AreEqual(1, value);

            dictionary.Remove("0");
            Assert.AreEqual(1, dictionary.Count);
            Assert.AreEqual(1, dictionary["1"]);
            Assert.IsFalse(dictionary.ContainsKey("0"));
            Assert.IsTrue(dictionary.ContainsKey("1"));

            Assert.IsFalse(dictionary.TryGetValue("0", out value));
            Assert.AreEqual(0, value);
            Assert.IsTrue(dictionary.TryGetValue("1", out value));
            Assert.AreEqual(1, value);

            dictionary.Clear();
            Assert.AreEqual(0, dictionary.Count);
            Assert.IsFalse(dictionary.ContainsKey("0"));
            Assert.IsFalse(dictionary.ContainsKey("1"));
        }
示例#2
0
 /// <summary>
 /// Closes this target.
 /// </summary>
 public override void Close()
 {
     _coordinates.Clear();
     _dataCache.Clear();
     _idTransformations.Clear();
     if (_nodesToCache != null)
     {
         _nodesToCache.Clear();
     }
     if (_waysToCache != null)
     {
         _waysToCache.Clear();
     }
     _preIndex      = null;
     _relevantNodes = null;
     _tagsIndex     = null;
 }
 /// <summary>
 /// Clears all coordinates from this index.
 /// </summary>
 public void Clear()
 {
     _coordinates.Clear();
 }