/// <summary> /// 요소의 속성 값을 인덱싱합니다. /// </summary> private static void AddToIndex(T item, string propertyName, MultiMap <int, T> index) { if (Equals(item, null)) { return; } object propertyValue = Accessor.GetPropertyValue(item, propertyName); if (IsDebugEnabled) { log.Debug("해당 요소[{0}] 의 속성 [{1}] 의 값은 [{2}] 입니다.", item, propertyName, propertyValue); } if (propertyValue != null) { var hash = propertyValue.GetHashCode(); if (index.ContainsKey(hash)) { index[hash].Add(item); } else { //List<T> newList = new List<T> {item}; //index.Add(hash, newList); index.Add(hash, item); } } }
private void LoadMetaData(object sender, RoutedEventArgs e) { //load images for comparison MultiMap<string, string> fileNamesToLocalPaths = new MultiMap<string, string>(StringComparer.CurrentCultureIgnoreCase); List<string> localPaths = Directory.GetFiles(Configuration.ImagesFolder, "*.*", SearchOption.AllDirectories).ToList(); localPaths.AddRange(Directory.GetFiles(Configuration.CameraFolder, "*.*", SearchOption.AllDirectories)); foreach (string path in localPaths) { string fileName = System.IO.Path.GetFileName(path); fileNamesToLocalPaths.Add(fileName, path); } foreach (SynergyRowObject sro in rowObjects) { sro.FileName = System.IO.Path.GetFileName(sro.DevicePath); int count = 0; if (fileNamesToLocalPaths.ContainsKey(sro.FileName)) { count = fileNamesToLocalPaths[sro.FileName].Count; } sro.FileNameMatchCount = count; } }
public bool AddValue(string value, MultiMap <Argument, object> argumentValues, CommandLineErrorReporter reporter) { if (!AllowMultiple && argumentValues.ContainsKey(this)) { reporter(string.Format(Resources.CommandLineArgumentParser_Argument_DuplicateArgument, LongName)); return(false); } object newValue; if (!ParseValue(ValueType, value, out newValue)) { reporter(string.Format(Resources.CommandLineArgumentParser_Argument_InvalidArgumentValue, LongName, value)); return(false); } if (Unique && argumentValues.Contains(this, newValue)) { reporter(string.Format(Resources.CommandLineArgumentParser_Argument_DuplicateArgumentValueExpectedUnique, LongName, value)); return(false); } argumentValues.Add(this, newValue); return(true); }
public void addInterest(String messageName, Entity e) { if (myMessageInterestMap.ContainsKey(messageName) == false) { myMessageInterestMap.Add(messageName, e); myEntityManager.addEventInterest(messageName); } else { //already added the event listener if (myMessageInterestMap[messageName].Contains(e) == false) { myMessageInterestMap.Add(messageName, e); } } }
public void tick(double dt) { //multithreaded message dispatch Event evt; while (myEventQueue.TryDequeue(out evt)) { if (myMessageInterestMap.ContainsKey(evt.name) == true) { List <Entity> interestedEntities = myMessageInterestMap[evt.name]; Parallel.ForEach(interestedEntities, ent => { Event levt = evt; ent.onMessage(levt); } ); } } //for each pass foreach (Int32 p in myPasses) { int updatesRemaining = 0; //for each bucket group (helps with dependencies) have to be done sequentially for (int b = 0; b < myUpdateableEntites.buckets.Count; b++) { //for each entity in group Parallel.ForEach(myUpdateableEntites.buckets[b], e => { System.Threading.Interlocked.Increment(ref updatesRemaining); int lp = p; e.onUpdate(lp, dt); System.Threading.Interlocked.Decrement(ref updatesRemaining); } ); } //wait for running tasks to finish while (updatesRemaining > 0) { System.Threading.Thread.Sleep(0); } } }
public void TestContainsKey() { var multi = new MultiMap <string, int> { { "coso", 1 }, { "coso", 2 }, { "coso", 3 } }; Assert.IsTrue(multi.ContainsKey("coso")); }
public List <Property> getInversePropertiesUsingTFSKey(String key) { if (inverseMapTFSKey.ContainsKey(key)) { return(inverseMapTFSKey[key]); } else { return(null); } }
public List <Property> getNotifyProperties(String key) { if (notifyMap.ContainsKey(key)) { return(notifyMap[key]); } else { return(null); } }
public void ContainsKey_VariousKeys_ReturnsStatus(string key, bool expectedStatus) { // Arrange var multiMap = new MultiMap <string, string>(); // Act multiMap.Add("yellow", "Sun"); // Assert Assert.True(multiMap.ContainsKey(key) == expectedStatus); }
public List <Property> getForwardProperties(String key) { // direction can be either FORWARD or BIDIRECTIONAL if (forwardMap.ContainsKey(key)) { List <Property> properties = forwardMap[key]; Predicate <Property> filterInverse = FilterInverse; properties.RemoveAll(filterInverse); return(properties); } return(null); }
public List <GameObject> GetUnregistered() { List <GameObject> unregistered = new List <GameObject>(); foreach (GameObject o in buttons) { if (o != null && !callbackMap.ContainsKey(o)) { unregistered.Add(o); } } return(unregistered); }
public (bool PermAppearance, bool TempAppearance) HasItemAppearance(uint itemModifiedAppearanceId) { if (itemModifiedAppearanceId < _appearances.Count && _appearances.Get((int)itemModifiedAppearanceId)) { return(true, false); } if (_temporaryAppearances.ContainsKey(itemModifiedAppearanceId)) { return(true, true); } return(false, false); }
public Tuple <bool, bool> HasItemAppearance(uint itemModifiedAppearanceId) { if (itemModifiedAppearanceId < _appearances.Count && _appearances.Get((int)itemModifiedAppearanceId)) { return(Tuple.Create(true, false)); } if (_temporaryAppearances.ContainsKey(itemModifiedAppearanceId)) { return(Tuple.Create(true, true)); } return(Tuple.Create(false, false)); }
public void Add_KeyDoesNotExist_AddsValueToNewListForKey() { // Arrange var multiMap = new MultiMap <string, string>(); // Act var key = "yellow"; var value = "Sun"; multiMap.Add(key, value); // Assert Assert.True(multiMap.ContainsKey(key) && multiMap[key].Contains(value)); }
public void NotifyOfModification(Annotation annotation) { bool belongsInIndex = _includeIndexPredicate(annotation); if (_keyToObjectsMap.ContainsKey(_keyMakingFunction(annotation))) { if (!belongsInIndex) { _keyToObjectsMap.RemoveAllItemsWithKey(_keyMakingFunction(annotation)); } } else { if (belongsInIndex) { _keyToObjectsMap.Add(_keyMakingFunction(annotation), annotation); } } }
/// <summary> /// Returns the list of productions whose id matches the specified name. Several named may be OR'ed together /// with pipes (|) to match more than one id. Note that several productions may also have the same id. /// </summary> private static List<Production> GetProductionsByRef(String name, MultiMap<string, ProductionNodePair> map) { String[] names = name.Split('|'); var list = new List<Production>(); foreach (String n in names) { if (!map.ContainsKey(n)) throw new ArgumentException(String.Format("No production exists with the name '{0}'", n)); List<ProductionNodePair> np = map[n]; foreach (ProductionNodePair pair in np) { list.Add(pair.Production); } } return list; }
private void Retrieve(NwdPortableDevice device, NwdPortableDeviceFolder folder, ref NwdUri uri, ref MultiMap<string, NwdPortableDeviceObject> found) { folder.Refresh(device); string nodeName = uri.PopNodeName(); if (found.ContainsKey(uri.CurrentTraversalUri)) { //used cached lookup foreach (NwdPortableDeviceObject pdo in found[uri.CurrentTraversalUri]) { ProcessPdo(device, pdo, ref uri, ref found); } } else { //use standard lookup if (folder.Files != null) { foreach (NwdPortableDeviceObject pdo in folder.Files) { if (NwdUri.MatchNodeName(nodeName, pdo.Name)) { ProcessPdo(device, pdo, ref uri, ref found); } } } } }
public void TestCase() { var map = new MultiMap<string,string>(); { map.Add("key1", "value11"); map.Add("key1", "value12"); map.Add("key1", "value13"); map.Add("key2", "value21"); map.Add("key2", "value22"); map.Add("key3", "value31"); } Assert.AreEqual(3, map.Keys.Count); CollectionAssert.AreEqual(new []{ "key1", "key2", "key3" }, map.Keys); Assert.AreEqual(3, map.Values.Count); Assert.IsTrue(map.ContainsKey("key1")); Assert.IsTrue(map.ContainsKey("key2")); Assert.IsTrue(map.ContainsKey("key3")); Assert.IsTrue(map.ContainsValue("value11")); Assert.IsTrue(map.ContainsValue("value12")); Assert.IsTrue(map.ContainsValue("value13")); Assert.IsTrue(map.ContainsValue("value21")); Assert.IsTrue(map.ContainsValue("value22")); Assert.IsTrue(map.ContainsValue("value31")); Assert.AreEqual(3, map["key1"].Count); CollectionAssert.AreEqual(new []{ "value11", "value12", "value13" }, map["key1"]); Assert.AreEqual(2, map["key2"].Count); CollectionAssert.AreEqual(new []{ "value21", "value22" }, map["key2"]); Assert.AreEqual(1, map["key3"].Count); CollectionAssert.AreEqual(new []{ "value31" }, map["key3"]); using (var tmpfile = new TemporaryFile()) { PersistenceHelper.SaveObj(map, tmpfile.FullName); var deserialized = PersistenceHelper.RestoreObj<MultiMap<string,string>>(tmpfile.FullName); Assert.AreEqual(3, deserialized.Keys.Count); CollectionAssert.AreEqual(new []{ "key1", "key2", "key3" }, deserialized.Keys); Assert.AreEqual(3, deserialized.Values.Count); Assert.IsTrue(deserialized.ContainsKey("key1")); Assert.IsTrue(deserialized.ContainsKey("key2")); Assert.IsTrue(deserialized.ContainsKey("key3")); Assert.IsTrue(deserialized.ContainsValue("value11")); Assert.IsTrue(deserialized.ContainsValue("value12")); Assert.IsTrue(deserialized.ContainsValue("value13")); Assert.IsTrue(deserialized.ContainsValue("value21")); Assert.IsTrue(deserialized.ContainsValue("value22")); Assert.IsTrue(deserialized.ContainsValue("value31")); } }
public void Test2() { Assert.IsTrue(_mmp.ContainsKey("Odd")); }
public bool HasSection(DeckSection section) => sections.ContainsKey(section);
public bool AddValue(string value, MultiMap<Argument, object> argumentValues, CommandLineErrorReporter reporter) { if (!AllowMultiple && argumentValues.ContainsKey(this)) { reporter(string.Format(Resources.CommandLineArgumentParser_Argument_DuplicateArgument, LongName)); return false; } object newValue; if (!ParseValue(ValueType, value, out newValue)) { reporter(string.Format(Resources.CommandLineArgumentParser_Argument_InvalidArgumentValue, LongName, value)); return false; } if (Unique && argumentValues.Contains(this, newValue)) { reporter(string.Format(Resources.CommandLineArgumentParser_Argument_DuplicateArgumentValueExpectedUnique, LongName, value)); return false; } argumentValues.Add(this, newValue); return true; }