private void RemoveLabels(WidgetType widgetType) { foreach (GameObject o in widgets[widgetType]) { foreach (UILabel l in o.GetComponentsInChildren <UILabel>()) { widgets.Remove(WidgetType.Label, l.gameObject); } } }
public void TestRemoveByKeyValuePair() { var multi = new MultiMap <string, int> { { "coso", 1 }, { "coso", 2 }, { "coso", 3 } }; Assert.IsTrue(multi.Remove(new KeyValuePair <string, int>("coso", 1))); Assert.IsTrue(multi.Count == 2); Assert.IsFalse(multi.Remove(new KeyValuePair <string, int>("coso", 5))); Assert.IsFalse(multi.Remove(new KeyValuePair <string, int>("cosos", 2))); }
//todo check this void AddItemAppearance(ItemModifiedAppearanceRecord itemModifiedAppearance) { Player owner = _owner.GetPlayer(); if (_appearances.Count <= itemModifiedAppearance.Id) { uint numBlocks = (uint)(_appearances.Count << 2); _appearances.Length = (int)itemModifiedAppearance.Id + 1; numBlocks = (uint)(_appearances.Count << 2) - numBlocks; while (numBlocks-- != 0) { owner.AddTransmogBlock(0); } } _appearances.Set((int)itemModifiedAppearance.Id, true); uint blockIndex = itemModifiedAppearance.Id / 32; uint bitIndex = itemModifiedAppearance.Id % 32; owner.AddTransmogFlag((int)blockIndex, 1u << (int)bitIndex); var temporaryAppearance = _temporaryAppearances.LookupByKey(itemModifiedAppearance.Id); if (!temporaryAppearance.Empty()) { owner.RemoveConditionalTransmog(itemModifiedAppearance.Id); _temporaryAppearances.Remove(itemModifiedAppearance.Id); } ItemRecord item = CliDB.ItemStorage.LookupByKey(itemModifiedAppearance.ItemID); if (item != null) { int transmogSlot = Item.ItemTransmogrificationSlots[(int)item.inventoryType]; if (transmogSlot >= 0) { _owner.GetPlayer().UpdateCriteria(CriteriaTypes.AppearanceUnlockedBySlot, (ulong)transmogSlot, 1); } } var sets = Global.DB2Mgr.GetTransmogSetsForItemModifiedAppearance(itemModifiedAppearance.Id); foreach (TransmogSetRecord set in sets) { if (IsSetCompleted(set.Id)) { _owner.GetPlayer().UpdateCriteria(CriteriaTypes.TransmogSetUnlocked, set.TransmogSetGroupID); } } }
private void ResumeContinuation(string continuationId) { while (continuationId != null) { IList <Continuation> continuations = continuationMap[continuationId]; if (continuations.Count == 0) { break; } continuationMap.Remove(continuationId); string nextContinuationId = null; foreach (Continuation continuation in continuations) { if (nextContinuationId == null) { nextContinuationId = continuation(); } else { continuationMap.Add(continuationId, continuation); } } continuationId = nextContinuationId; } }
static void Main() { var n = int.Parse(Console.ReadLine()); var r = new List <string>(); var set = new SortedSet <string>(); var d = new MultiMap <string, string>(); for (int i = 0; i < n; i++) { var q = Console.ReadLine().Split(); if (q[0] == "0") { set.Add(q[1]); d.Add(q[1], q[2]); } else if (q[0] == "1") { r.AddRange(d.ReadValues(q[1])); } else if (q[0] == "2") { d.Remove(q[1]); set.Remove(q[1]); } else { r.AddRange(set.GetViewBetween(q[1], q[2]).SelectMany(x => d[x].Select(v => $"{x} {v}"))); } } Console.WriteLine(string.Join("\n", r)); }
protected bool RemoveInterceptor(string methodName, IInterceptor interceptor) { MethodInfo method = GetSampleMethod(methodName); bool result = instrumentor.RemoveInterceptor(method, interceptor); interceptors.Remove(method, interceptor); return(result); }
public void removeInterest(String messageName, Entity e) { myMessageInterestMap.Remove(messageName, e); if (myMessageInterestMap.ContainsKey(messageName) == false) { myEntityManager.removeEventInterest(messageName); } }
public void removeInterest(String messageName, Entity e) { myMessageInterestMap.Remove(messageName, e); if (myMessageInterestMap.ContainsKey(messageName) == false) { Application.eventManager.removeListener(eventListener, messageName); } }
public void RemoveAt(int index) { searchHelper.Remove( graph.GetNode(index).ID, index, RemoveOption.RemoveFirst); graph.RemoveNode(index); }
public void Remove_RemovesItemFromTheCorrectCollection() { var map = new MultiMap<int, string>(); map.AddRange(1, new []{"1", "2", "3"}); map.AddRange(42, new [] { "42", "42", "42"}); map.Remove(1, "2"); Assert.IsTrue(map[1].SequenceEqual(new []{"1", "3"})); Assert.IsTrue(map[42].SequenceEqual(new []{"42", "42", "42"})); }
private void GetWWW(string url, bool dispose, Action <WWW> callback) { callbacks.Add(url, callback); if (callbacks.GetCount(url) > 1) { return; } Threading.inst.StartCoroutine(GetWWWCo(url, dispose, www => { List <Action <WWW> > slot = callbacks.GetSlot(url); callbacks.Remove(url); slot.ForEach(s => s(www)); })); }
public void GetAsset <T>(string alias, string url, Action <T> callback, bool asyncHint = false) where T : Object { VerifyUrl(url); if (!url.IsEmpty()) { T o = assetCache.Get(url) as T; if (o != null) { callback(o); } else { callbacks.Add(url, callback); if (callbacks.GetCount(url) == 1) { log.Debug("Loading {0}", url); loader.GetAsset <T>(pathConverter(url), a => { if (a != null) { AddToCache(alias, url, a); } List <Delegate> slot = callbacks.GetSlot(url); callbacks.Remove(url); foreach (Delegate c in slot) { ((Action <T>)c)(a); } }, asyncHint); } } } else { callback(null); } }
private void GetWWW(string url, bool dispose, Action <WWW> callback) { callbacks.Add(url, callback); if (callbacks.GetCount(url) > 1) { return; } GetFileCache(url, f => { if (f != null) { Threading.inst.StartCoroutine(LoadWWWAsync(f, dispose, www => { List <Action <WWW> > slot = callbacks.GetSlot(url); callbacks.Remove(url); slot.ForEach(s => s(www)); })); } else { List <Action <WWW> > slot = callbacks.GetSlot(url); callbacks.Remove(url); slot.ForEach(s => s(null)); } }); }
public void TestRemove() { var multi = new MultiMap <string, int> { { "coso", 1 }, { "coso", 2 }, { "coso", 3 } }; Assert.IsTrue(multi.Remove("coso")); Assert.IsTrue(multi.Count == 0); var multi2 = new MultiMap <string, int> { { "coso", 1 }, { "coso", 2 }, { "coso", 3 }, { "cosa", 5 } }; Assert.IsTrue(multi2.Remove("coso")); Assert.IsTrue(multi2.Count == 1); }
private void RegisterCallback(object buttonId, Action callback, bool clear) { string buttonName = buttonId.ToText(); GameObject obj = buttonMap.Get(buttonName); if (obj == null) { log.Error("'{0}' isn't added to button list", buttonName); } else { if (clear) { callbackMap.Remove(obj); } callbackMap.Add(obj, callback); } }
private void RemoveSingle() { foreach (UIWidgetClassifier.WidgetType widgetType in EnumUtil.Values <UIWidgetClassifier.WidgetType>()) { MultiMap <string, DupEntry> slot = dups[widgetType]; List <string> names = new List <string>(); foreach (KeyValuePair <string, List <DupEntry> > entry in slot) { if (entry.Value.Count == 1) { names.Add(entry.Key); } } foreach (string s in names) { slot.Remove(s); } } }
public override List <Value2D <T> > GetRandom(System.Random random, int amount, int distance = 0, bool take = false) { MultiMap <T> removed = new MultiMap <T>(); List <Value2D <T> > list = new List <Value2D <T> >(); if (distance < 0) { distance = 0; } for (int i = 0; i < amount; i++) { Value2D <T> g = RandomValue(random); if (g == null) { return(list); } if (distance > 0) { for (int yCur = g.y - distance; yCur <= g.y + distance; yCur++) { for (int xCur = g.x - distance; xCur <= g.x + distance; xCur++) { removed[g] = g.val; Remove(xCur, yCur); } } } Remove(g.x, g.y, distance - 1); list.Add(g); } if (take) { foreach (Value2D <T> val in list) { removed.Remove(val); } } this.PutAll(removed); return(list); }
static void Main() { var n = int.Parse(Console.ReadLine()); var qs = new int[n].Select(_ => Console.ReadLine().Split()).ToArray(); var keys = qs.Select(q => q[1]).Concat(qs.Where(q => q[0] == "3").Select(q => q[2])).Distinct().ToArray(); Array.Sort(keys); var keymap = Enumerable.Range(0, keys.Length).ToDictionary(i => keys[i], i => i); var r = new List <string>(); var set = new SortedSet <int>(); var d = new MultiMap <int, string>(); foreach (var q in qs) { var keyInt = keymap[q[1]]; if (q[0] == "0") { set.Add(keyInt); d.Add(keyInt, q[2]); } else if (q[0] == "1") { r.AddRange(d.ReadValues(keyInt)); } else if (q[0] == "2") { d.Remove(keyInt); set.Remove(keyInt); } else { r.AddRange(set.GetViewBetween(keyInt, keymap[q[2]]).SelectMany(x => d[x].Select(v => $"{keys[x]} {v}"))); } } Console.WriteLine(string.Join("\n", r)); }
public void removePassInterest(Int32 pass, Behavior behavior) { myBehaviorPassInterestMap.Remove(pass, behavior); }
public void removeEventInterest(String eventType, Behavior behavior) { myMessageInterestMap.Remove(eventType, behavior); myManager.removeInterest(eventType, this); }
/** * Return a polygon which is the union of the given polygons; combines * vertices that form edges that are almost identical, as defined by * vertexMergeRadius. Note: clears the List! */ public static S2Polygon DestructiveUnionSloppy(System.Collections.Generic.ICollection <S2Polygon> polygons, S1Angle vertexMergeRadius) { // Effectively create a priority queue of polygons in order of number of // vertices. Repeatedly union the two smallest polygons and add the result // to the queue until we have a single polygon to return. // map: # of vertices -> polygon //TreeMultimap<Integer, S2Polygon> queue = TreeMultimap.create(); var queue = new MultiMap <int, S2Polygon>(); foreach (var polygon in polygons) { queue.Add(polygon.NumVertices, polygon); } polygons.Clear(); // Java uses a live-view that maps to the underlying structure //Set<Map.Entry<Integer, S2Polygon>> queueSet = queue.entries(); var enumer = queue.SortedValues; while (queue.CountIsAtLeast(2)) { // Pop two simplest polygons from queue. // queueSet = queue.entries(); //Iterator<Map.Entry<Integer, S2Polygon>> smallestIter = queueSet.iterator(); var smallestTwo = enumer.Take(2).ToList(); //Map.Entry<Integer, S2Polygon> smallest = smallestIter.next(); //int aSize = smallest.getKey().intValue(); //S2Polygon aPolygon = smallest.getValue(); //smallestIter.remove(); //smallest = smallestIter.next(); //int bSize = smallest.getKey().intValue(); //S2Polygon bPolygon = smallest.getValue(); //smallestIter.remove(); foreach (var item in smallestTwo) { queue.Remove(item); } // Union and add result back to queue. var unionPolygon = new S2Polygon(); unionPolygon.InitToUnionSloppy(smallestTwo[0].Value, smallestTwo[1].Value, vertexMergeRadius); var unionSize = smallestTwo[0].Key + smallestTwo[1].Key; queue.Add(unionSize, unionPolygon); // We assume that the number of vertices in the union polygon is the // sum of the number of vertices in the original polygons, which is not // always true, but will almost always be a decent approximation, and // faster than recomputing. } if (queue.Count == 0) { return(new S2Polygon()); } else { //return queue.get(queue.asMap().firstKey()).first(); return(queue.SortedValues.First().Value); } }
/** If a recursion overflow is resolve with predicates, then we need * to shut off the warning that would be generated. */ public virtual void RemoveRecursiveOverflowState(DFAState d) { _stateToRecursionOverflowConfigurationsMap.Remove(d.stateNumber); }
public void removePassInterest(String pass, Behavior behavior) { int passId = SimManager.entityManager.updatePassId(pass); myBehaviorPassInterestMap.Remove(passId, behavior); }