private static void TestClear(HashMap<int, string> map) { Console.WriteLine("Test Clear:"); map.Clear(); Console.WriteLine("after clear #1, map = {0}, size = {1}, IsEmpty = {2}", map, map.Count, map.IsEmpty()); map.Clear(); Console.WriteLine("after clear #2, map = {0}, size = {1}, IsEmpty = {2}", map, map.Count, map.IsEmpty()); }
public void InvalidateAll() { lock (serviceCallToPendingResult) { serviceCallToResult.Clear(); } }
public void ObjToObjStressTest() { int numberOfIteration = 2000000; HashMap <BinaryArray, Int32> myHashMap = new HashMap <BinaryArray, Int32>(-1); Dictionary <BinaryArray, Int32> etalon = new Dictionary <BinaryArray, int>(); Random rand = new Random(55); for (int i = 0; i < numberOfIteration; ++i) { if (rand.Next(3) != 0) { BinaryArray ar = new BinaryArray().Assign(i); etalon.Add(ar, i); myHashMap[ar] = i; Assert.AreEqual(etalon[ar], myHashMap[ar]); } else { int x = rand.Next(i); BinaryArray ar = new BinaryArray().Assign(x); Assert.AreEqual(etalon.ContainsKey(ar), myHashMap.ContainsKey(ar)); if (myHashMap.ContainsKey(ar)) { myHashMap.Remove(ar); etalon.Remove(ar); } } if (i % 1000000 == 0) { myHashMap.Clear(); etalon.Clear(); } } }
private void RedrawPhones() { HashMap phoneCopies = new HashMap(); foreach (HashMap.Entry E in _phoneControls) { Label label = (Label)E.Key; Control ctl = (Control)E.Value; phoneCopies.Add(label.Text, ctl.Text); Controls.Remove(label); Controls.Remove(ctl); } _phoneControls.Clear(); _editPhoneName.Location = new Point(_editPhoneName.Left, cInitialY); _addPhoneButton.Location = new Point(_addPhoneButton.Left, cInitialY); foreach (HashMap.Entry E in phoneCopies) { string phoneName = (string)E.Key; string phoneValue = (string)E.Value; AddPhone(phoneName.Substring(0, phoneName.Length - 1), (phoneValue == NotSpecified) ? null : phoneValue, false); } UpdateHeight(); }
public void HandleClearAllCachesEvent(ClearAllCachesEvent evnt) { lock (writeLock) { xmlFileNamesConfigGroupMap.Clear(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void resetTokens(String[] inputTokens, String defaultRootLabel, boolean addEdges) throws org.maltparser.core.exception.MaltChainedException public void resetTokens(string[] inputTokens, string defaultRootLabel, bool addEdges) { nodes.Clear(); comments.Clear(); symbolTables.cleanUp(); // Add nodes nodes.Add(new LWNode(this, 0)); // ROOT for (int i = 0; i < inputTokens.Length; i++) { nodes.Add(new LWNode(this, i + 1)); } for (int i = 0; i < inputTokens.Length; i++) { nodes[i + 1].addColumnLabels(inputTokens[i].Split(TAB_SIGN, true), addEdges); } // Check graph for (int i = 0; i < nodes.Count; i++) { if (nodes[i].HeadIndex >= nodes.Count) { throw new LWGraphException("Not allowed to add a head node that doesn't exists"); } } for (int i = 0; i < dataFormat.NumberOfColumns(); i++) { ColumnDescription column = dataFormat.GetColumnDescription(i); if (!column.Internal && column.Category == ColumnDescription.DependencyEdgeLabel) { rootLabels.setDefaultRootLabel(symbolTables.getSymbolTable(column.Name), defaultRootLabel); } } }
public void test_PropertyChange_ToBeUpdated() { HashMap <String, int> pceCounter = new HashMap <String, int>(); PropertyChangedEventHandler handler = GetPropertyChangeHandler(pceCounter); Material obj = EntityFactory.CreateEntity <Material>(); ((INotifyPropertyChanged)obj).PropertyChanged += handler; obj.Id = 1; WaitForUI(); Assert.AssertEquals(1, pceCounter.Get("Id")); Assert.AssertEquals(1, pceCounter.Get("ToBeCreated")); Assert.AssertEquals(1, pceCounter.Get("ToBeUpdated")); Assert.AssertEquals(2, pceCounter.Get("HasPendingChanges")); Assert.AssertEquals(4, pceCounter.Count); pceCounter.Clear(); obj.Id = null; WaitForUI(); Assert.AssertEquals(1, pceCounter.Get("Id")); Assert.AssertEquals(1, pceCounter.Get("ToBeCreated")); Assert.AssertEquals(1, pceCounter.Get("ToBeUpdated")); Assert.AssertEquals(2, pceCounter.Get("HasPendingChanges")); Assert.AssertEquals(4, pceCounter.Count); }
internal void Clear() { lock ( _formatCache ) { _formatCache.Clear(); } }
public void Dispose() { foreach (var node in this.nodes.Values) { node.Dispose(); } nodes.Clear(); }
/// <summary> /// 销毁对象 /// </summary> public virtual void delete() { if (!m_isDisposed) { m_listeners.Clear(); m_isDisposed = true; } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void clear() throws org.maltparser.core.exception.MaltChainedException public override void Clear() { terminalPool.checkInAll(); terminalNodes.Clear(); comments.Clear(); sentenceID = 0; base.Clear(); }
internal void Clear() { terms.Clear(); queries.Clear(); docIDs.Clear(); numTerms = 0; bytesUsed = 0; }
internal void Clear() { using (lock_rw.EnterWrite()) { groupSessionsMap.Clear(); sessionsMap.Clear(); } }
private void ShutdownImpl() { if (_database != null) { _database.Shutdown(); _database = null; } _dirty = false; _tables.Clear(); }
public void ClearTest() { HashMap <StringKey, Item> hashMap = new HashMap <StringKey, Item>(5, 0.75); hashMap.Put(new StringKey("Test"), new Item("Test", 1, 0.75)); hashMap.Clear(); Assert.AreEqual(0, hashMap.Size()); }
/** * /// Called after the lex tree is built. Frees all temporary structures. After this is called, no more words can be * /// added to the lex tree. */ private void Freeze() { _entryPointTable.Freeze(); Dictionary = null; _lm = null; ExitPoints = null; _allWords = null; WordNodeMap.Clear(); _endNodeMap.Clear(); }
private void ClearAll() { _flatList = true; _rootNode.ClearChildren(); _nodeMap.Clear(); lock ( _comparerMap ) { _comparerMap.Clear(); } OnMultipleNodesChanged(); }
/// <summary> Construct a FieldInfos object using the directory and the name of the file /// IndexInput /// </summary> /// <param name="d">The directory to open the IndexInput from /// </param> /// <param name="name">The name of the file to open the IndexInput from in the Directory /// </param> /// <throws> IOException </throws> public /*internal*/ FieldInfos(Directory d, String name, IState state) { IndexInput input = d.OpenInput(name, state); try { try { Read(input, name, state); } catch (System.IO.IOException) { if (format == FORMAT_PRE) { // LUCENE-1623: FORMAT_PRE (before there was a // format) may be 2.3.2 (pre-utf8) or 2.4.x (utf8) // encoding; retry with input set to pre-utf8 input.Seek(0, state); input.SetModifiedUTF8StringsMode(); byNumber.Clear(); byName.Clear(); bool rethrow = false; try { Read(input, name, state); } catch (Exception) { // Ignore any new exception & set to throw original IOE rethrow = true; } if (rethrow) { // Preserve stack trace throw; } } else { // The IOException cannot be caused by // LUCENE-1623, so re-throw it throw; } } } finally { input.Close(); } }
public static void ClearEmptiesTableTest() { HashMap <StringKey, Item> hashMap = new HashMap <StringKey, Item>(); StringKey key = new StringKey("item"); hashMap.Put(key, new Item("item", 1, 1.0)); // make sure to actually clear the hashmap before testing... :| hashMap.Clear(); Assert.AreEqual(null, hashMap.Get(key)); Assert.IsTrue(hashMap.IsEmpty()); Assert.AreEqual(0, hashMap.Size()); }
public void test_DataObject_PropertyChange() { MaterialType obj = EntityFactory.CreateEntity <MaterialType>(); Assert.IsInstanceOfType(obj, typeof(IDataObject)); Assert.IsInstanceOfType(obj, typeof(INotifyPropertyChanged)); Assert.IsInstanceOfType(obj, typeof(INotifyPropertyChangedSource)); HashMap <String, int> propertyNameToHitCountMap = new HashMap <String, int>(); PropertyChangedEventHandler handler = GetPropertyChangeHandler(propertyNameToHitCountMap); ((INotifyPropertyChanged)obj).PropertyChanged += handler; Assert.AssertEquals(0, propertyNameToHitCountMap.Count); obj.Id = 1; WaitForUI(); Assert.AssertEquals(4, propertyNameToHitCountMap.Count); Assert.AssertEquals(1, propertyNameToHitCountMap.Get("Id")); Assert.AssertEquals(1, propertyNameToHitCountMap.Get("ToBeCreated")); Assert.AssertEquals(1, propertyNameToHitCountMap.Get("ToBeUpdated")); Assert.AssertEquals(2, propertyNameToHitCountMap.Get("HasPendingChanges")); ((IDataObject)obj).ToBeUpdated = false; propertyNameToHitCountMap.Clear(); obj.Name = "name2"; WaitForUI(); Assert.AssertEquals(5, propertyNameToHitCountMap.Count); Assert.AssertEquals(1, propertyNameToHitCountMap.Get("Name")); Assert.AssertEquals(1, propertyNameToHitCountMap.Get("Temp1")); Assert.AssertEquals(1, propertyNameToHitCountMap.Get("Temp2")); Assert.AssertEquals(2, propertyNameToHitCountMap.Get("ToBeUpdated")); Assert.AssertEquals(2, propertyNameToHitCountMap.Get("HasPendingChanges")); propertyNameToHitCountMap.Clear(); }
public virtual void LoadServerList(string serverListPath) { serverList.Clear(); groupList.Clear(); recommendServers.Clear(); try { log.Info("Load Server From : " + serverListPath); ServerInfo.LoadServerList(serverListPath, serverList, groupList, recommendServers); } catch (Exception err) { throw new Exception("Load Server List Error From : " + serverListPath, err); } }
private void Init() { _codePage = -1; _curState = new State(); _states.Clear(); _plainText.Length = 0; if (_plainText.Capacity > 16384) { _plainText.Capacity = 1024; } _currentPosition = -1; _groupDeepCount = 0; _fonts.Clear(); _parameter = -1; _fontNum = -1; _fontTableProcessed = false; }
public void test_PropertyChange_Registration() { HashMap <String, int> pceCounter = new HashMap <String, int>(); PropertyChangedEventHandler handler = GetPropertyChangeHandler(pceCounter); { MaterialType obj = EntityFactory.CreateEntity <MaterialType>(); Assert.IsInstanceOfType(obj, typeof(INotifyPropertyChanged)); Assert.IsInstanceOfType(obj, typeof(INotifyPropertyChangedSource)); ((INotifyPropertyChanged)obj).PropertyChanged += handler; obj.Name = "name2"; obj.Version = 1; WaitForUI(); Assert.AssertEquals(4, pceCounter.Count); Assert.AssertEquals(1, pceCounter.Get("Name")); Assert.AssertEquals(1, pceCounter.Get("Temp1")); Assert.AssertEquals(1, pceCounter.Get("Temp2")); Assert.AssertEquals(1, pceCounter.Get("Version")); } { Material obj = EntityFactory.CreateEntity <Material>(); Assert.IsInstanceOfType(obj, typeof(INotifyPropertyChanged)); Assert.IsInstanceOfType(obj, typeof(INotifyPropertyChangedSource)); Assert.IsInstanceOfType(obj, typeof(IDataObject)); obj.Id = 1; ((IDataObject)obj).ToBeUpdated = false; ((INotifyPropertyChanged)obj).PropertyChanged += handler; pceCounter.Clear(); Assert.IsInstanceOfType(obj.Names, typeof(ObservableCollection <String>)); obj.Names.Add("Item1"); obj.Names.Add("Item2"); WaitForUI(); Assert.AssertEquals(2, pceCounter.Count); Assert.AssertEquals(1, pceCounter.Get("ToBeUpdated")); Assert.AssertEquals(1, pceCounter.Get("HasPendingChanges")); } }
public void Count() { HashMap <int, string> map = new HashMap <int, string>(); map.Add(1, "a"); map.Add(2, "b"); map.Add(3, "c"); Assert.Equal(3, map.Count); map.Remove(2); Assert.Equal(2, map.Count); map.Clear(); Assert.Equal(0, map.Count); }
public void Reset() { CurrentEventHandlerSignature = null; CurrentEventHandlerContext = null; CurrentFunctionBodySignature = null; CurrentFunctionContext = null; CurrentScopeId = 0; _scopeVariables.Clear(); _controlStatementStack.Clear(); _definedStates.Clear(); _functionDefinitions.Clear(); _globalVariables.Clear(); _labelScopes.Clear(); _parameterScopeVariables.Clear(); _scopeStack.Clear(); _scopeTypeStack.Clear(); _singleStatementScopeTrackingStack.Clear(); }
public void ObjToObjLocateStressTest() { int numberOfIteration = 2000000; HashMap <BinaryArray, Int32> myHashMap = new HashMap <BinaryArray, Int32>(-1); Dictionary <BinaryArray, Int32> etalon = new Dictionary <BinaryArray, Int32>(); Random rand = new Random(55); for (int i = 0; i < numberOfIteration; ++i) { if (rand.Next(3) != 0) { BinaryArray ar = new BinaryArray().Assign(i); etalon[ar] = i; long iterator = myHashMap.LocateOrReserve(ar); myHashMap.SetKeyAt(iterator, ar); myHashMap.SetValueAt(iterator, i); Assert.AreEqual(myHashMap[ar], etalon[ar]); } else { int x = rand.Next(i); BinaryArray ar = new BinaryArray().Assign(x); Assert.AreEqual(etalon.ContainsKey(ar), myHashMap.ContainsKey(ar)); if (myHashMap.ContainsKey(ar)) { long key = myHashMap.Locate(ar); Assert.AreEqual(true, myHashMap.GetKeyAt(myHashMap.Locate(ar)).Equals(ar)); Assert.AreEqual(x, myHashMap.GetValueAt(myHashMap.Locate(ar))); myHashMap.RemoveAt(key); etalon.Remove(ar); } Assert.AreEqual(etalon.ContainsKey(ar), myHashMap.ContainsKey(ar)); } if (i % 1000000 == 0) { myHashMap.Clear(); etalon.Clear(); } } }
public void TestMap() { Map<String, String> map = new HashMap<String, String>(); map["A"] = "a"; map["B"] = "b"; map["C"] = "c"; AssertFalse(map.Empty); AssertEquals(map.Size, 3); AssertEquals(map["A"], "a"); AssertEquals(map["B"], "b"); AssertEquals(map["C"], "c"); List<String> order = new List<String>(); foreach(String key in map.Keys) { order.Add(key); } AssertEquals(map.Keys[0], order[0]); AssertEquals(map.Keys[1], order[1]); AssertEquals(map.Keys[2], order[2]); map.Clear(); AssertTrue(map.Empty); AssertEquals(map.Size, 0); AssertEquals(map.Keys.Count, 0); }
public static void Uninitialize() { foreach (HashMap.Entry entry in _msgStores) { IEMsgStore msgStore = (IEMsgStore)entry.Value; if (msgStore != null) { msgStore.Unadvise(); msgStore.Dispose(); } } if (_defaultMsgStore != null) { _defaultMsgStore.Dispose(); } if (_addressBook != null) { _addressBook.Dispose(); } _msgStores.Clear(); _eSession.Uninitialize(); //_eSession.Dispose(); // TODO:Convert: call dtor!!! _eSession = null; }
public void PostProcessCreatedType(Type newType) { foreach (Entry <String, IValueResolveDelegate> entry in initializeStaticFields) { FieldInfo[] fields = ReflectUtil.GetDeclaredFieldInHierarchy(newType, entry.Key); if (fields.Length == 0) { throw new Exception("Field not found: '" + newType.FullName + "." + entry.Key); } Object value = entry.Value.Invoke(entry.Key, newType); foreach (FieldInfo field in fields) { try { field.SetValue(null, value); } catch (Exception e) { throw RuntimeExceptionUtil.Mask(e, "Error occured while setting field: " + field); } } } initializeStaticFields.Clear(); }
static void Main(string[] args) { IMap<string, int> map = new HashMap<string, int>(); map.Put("yellow", 1); map.Put("blue", 10); map.Put("red", 67); while(true) { string[] command = Console.ReadLine().Split(' '); try { switch (command[0].ToLower()) { case "clear": map.Clear(); break; case "put": map.Put(command[1], Convert.ToInt32(command[2])); break; case "remove": map.Remove(command[1]); break; case "containskey": Console.WriteLine(map.ContainsKey(command[1])); break; case "containsvalue": Console.WriteLine(map.ContainsValue(Convert.ToInt32(command[1]))); break; case "list": foreach (IEntry<string, int> e in map) Console.WriteLine(e.ToString()); break; case "keys": foreach (string s in map.Keys) Console.WriteLine(s); break; case "values": foreach (int i in map.Values) Console.WriteLine(i.ToString()); break; case "testum": //test UnmutableMap<string, int> um = new UnmutableMap<string, int>(map); Console.WriteLine(um["red"].ToString()); um["red"] = 3; break; case "testfind": map = MapUtilsGeneric<string, int>.FindAll(map, new MapUtilsGeneric<string, int>.CheckDelegate( (Entry<string, int> e) => { return e.Key[0] == 'r'; } ), MapUtilsGeneric<string, int>.ArrayMapConstructor); break; default: throw new Exception("Unknown command."); } } catch (Exception ex) { Console.WriteLine(ex.GetType().ToString() + ": " + ex.Message); } } }
public void ClearTest() { hash.Add(12); hash.Clear(); Assert.IsFalse(hash.Contains(12)); }
static void Main(string[] args) { int RowCount = 20; HashMap <string, string> ConcertProgram = new HashMap <string, string>(RowCount); Console.WriteLine("Воспользуйтесь меню для управлениями номерами концерта"); Console.WriteLine("МЕНЮ\n" + "1 - Вывести содержимое концертной программы\n" + "2 - Добавить номер\n" + "3 - Удалить номер\n" + "4 - Проверить существование номера(ключ)\n" + "5 - Узнать участвует ли исполнитель в концерте\n" + "6 - Вывести количество номеров(пар ключ-значение)\n" + "7 - Проверить таблицу на пустоту\n" + "8 - Узнать исполнителя по произведению\n" + "9 - Очистить таблицу\n" + "10 - Завершить\n"); int act; do { string strAct = Console.ReadLine(); if (!Int32.TryParse(strAct, out act)) { Console.WriteLine("Неверный формат ввода, попробуйте еще раз"); } else { switch (act) { case 1: Console.WriteLine(ConcertProgram); break; case 2: Console.WriteLine("Введите название номера(ключ)"); string Key2 = Console.ReadLine(); Console.WriteLine("Введите имя исполнителя(значение)"); string Value2 = Console.ReadLine(); ConcertProgram.Put(Key2, Value2); if (Key2 == "" || Value2 == "") { Console.WriteLine("Операция вставки была не выполнена, попробуйте снова"); } else { Console.WriteLine("Операция вставки выполнена"); } break; case 3: //test Console.WriteLine("Введите название номера(ключ), который вы хотите удалить"); string Key3 = Console.ReadLine(); ConcertProgram.Remove(Key3); Console.WriteLine("Удаление завершено"); break; case 4: Console.WriteLine("Введите название номера(ключ), который вы хотите проверить"); string Key4 = Console.ReadLine(); if (!ConcertProgram.ContainsKey(Key4)) { Console.WriteLine($"Номер с названием {Key4} НЕ включен в концертную программу"); break; } Console.WriteLine($"Номер с названием {Key4} включен в концертную программу"); break; case 5: Console.WriteLine("Введите имя исполнителя(значение), которое вы хотите проверить"); string Value5 = Console.ReadLine(); if (ConcertProgram.ContainsValue(Value5)) { Console.WriteLine($"Номер с названием {Value5} включен в концертную программу"); } else { Console.WriteLine($"Номер с названием {Value5} НЕ включен в концертную программу"); } break; case 6: Console.WriteLine($"В концертной программе {ConcertProgram.Count} номеров"); break; case 7: if (ConcertProgram.IsEmpty) { Console.WriteLine("В концертной программе нет номеров(таблица пуста)"); } else { Console.WriteLine("В концертной программе есть номера(таблица не пуста)"); } break; case 8: Console.WriteLine("Введите название номера(ключ)"); string Key8 = Console.ReadLine(); try { Console.WriteLine($"Исполнитель(значение) - {ConcertProgram[Key8]}"); } catch (Exception ex) { Console.WriteLine($"Ошибка: {ex.Message}"); } break; case 9: ConcertProgram.Clear(); Console.WriteLine("Все номера удалены из программы"); break; case 10: act = 10; break; } } } while (act != 10); }