public void RemoveTest() { var a = new SparseArray <bool> { [5] = true, [90] = false }; a.Remove(true); Assert.That(a.Count, Is.EqualTo(1)); a.Remove(true); Assert.That(a.Count, Is.EqualTo(1)); }
public void RemoveTest() { int count = _array.Count; bool isRemoved = _array.Remove(80); Assert.True(isRemoved); Assert.Equal(count - 1, _array.Count); Assert.DoesNotContain(80, _array); Assert.Equal(-1, _array.IndexOf(80)); Assert.False(_array.Remove(100)); }
public void Remove_ValueExists() { var sa = new SparseArray <decimal>(2, new Dictionary <int, decimal>() { { 0, 1M }, { 1, 2M } }); Assert.AreEqual(2, sa.Capacity, "Incorrect capacity."); Assert.AreEqual(2, sa.Count, "Incorrect count."); Assert.AreEqual(2, sa.Sparsity, "Incorrect sparsity."); Assert.AreEqual(1.0M, sa.SparsityPercent, "Incorrect sparsity percent."); Assert.IsTrue(sa.Keys.SequenceEqual(new List <int> { 0, 1 }), "Incorrect keys."); Assert.IsTrue(sa.ToArray().SequenceEqual(new[] { 1M, 2M }), "Unequal elements in sparse array"); Assert.IsTrue(sa.Remove(2M), "Incorrect return result for removing existing value."); Assert.AreEqual(2, sa.Capacity, "Incorrect capacity after Remove(...)."); Assert.AreEqual(2, sa.Count, "Incorrect count after Remove(...)."); Assert.AreEqual(1, sa.Sparsity, "Incorrect sparsity after Remove(...)."); Assert.AreEqual(0.5M, sa.SparsityPercent, "Incorrect sparsity percent after Remove(...)."); Assert.IsTrue(sa.Keys.SequenceEqual(new List <int> { 0 }), "Incorrect keys after Remove(...)."); Assert.IsTrue(sa.ToArray().SequenceEqual(new[] { 1M, decimal.Zero }), "Unequal elements in sparse array after Remove(...)"); }
public override void DestroyItem(ViewGroup container, int position, Object obj) { if (0 <= _pages.IndexOfKey(position)) { _pages.Remove(position); } base.DestroyItem(container, position, obj); }
/// <summary> /// Removes the given entity from the index. /// </summary> internal void RemoveEntity(IEntity entity) { bool success = _entities.Remove(entity.UniqueId); if (success == false) { throw new InvalidOperationException("Failed to remove entity " + entity + " from the entity index"); } }
public void SparseArrayRemoveTest() { SparseArray <Int32> array = new SparseArray <Int32>(_values); Assert.IsFalse(array.Remove(-1)); Assert.AreEqual(_values.Length, array.Length); Assert.IsTrue(array.Remove(0)); Assert.AreEqual(_values.Length - 1, array.Length); Assert.IsTrue(array.Remove(0)); Assert.AreEqual(_values.Length - 2, array.Length); Assert.IsTrue(array.Remove(1)); Assert.AreEqual(_values.Length - 3, array.Length); for (Int32 i = 0; i < array.Count; i++) { Assert.AreEqual(_values[3 + i], array[i]); } }
/** * Cancels any existing animations for given View. */ ////@NonNull readonly public void cancelExistingAnimation(View view) { int hashCode = view.GetHashCode(); Animator animator = mAnimators.Get(hashCode); if (animator != null) { animator.End(); mAnimators.Remove(hashCode); } }
public static IntentExtras FromIdAndRelease(int id) { var map = ExtraStore.Get(id); if (map == null) { return(null); } ExtraStore.Remove(id); return(new IntentExtras(id, map)); }
/// <summary> /// Remove the window corresponding to the id from the <seealso cref="#sWindows"/> /// cache. /// </summary> /// <param name="id"> /// The id representing the window. </param> /// <param name="cls"> /// The class of the implementation of the window. </param> public virtual void RemoveCache(int id, Type cls) { SparseArray <Window> l2 = SWindows.GetValueOrNull(cls); if (l2 != null) { l2.Remove(id); if (l2.Size() == 0) { SWindows.Remove(cls); } } }
public void SparseArrayRemoveTest() { SparseArray <Int32> array = new SparseArray <Int32>(this.values); array.Length.ShouldBe(this.values.Length); array.Remove(-1).ShouldBeFalse(); array.Length.ShouldBe(this.values.Length); array.Remove(0).ShouldBeTrue(); array.Length.ShouldBe(this.values.Length - 1); array.Remove(0).ShouldBeFalse(); array.Length.ShouldBe(this.values.Length - 1); array.Remove(5).ShouldBeTrue(); array.Length.ShouldBe(this.values.Length - 2); for (Int32 index = 0; index < array.Count; index++) { array[index].ShouldBe(this.values[2 + index]); } }
private void OnEntityDestroyed(IEntity entity) { SparseArray <DataRenderer> renderers; if (_renderers.TryGetValue(entity.UniqueId, out renderers)) { foreach (KeyValuePair <int, DataRenderer> renderer in renderers) { renderer.Value.Dispose(); } } _renderers.Remove(entity.UniqueId); }
public void filter(FaceInfo[] infos, ImageFrame frame) { currentFrame.Clear(); if (infos != null) { foreach (FaceInfo faceInfo in infos) { TrackedModel face = getTrackedModel(faceInfo, frame); currentFrame.Add(face); face.setInfo(faceInfo); } } leftFaces.Clear(); for (int i = 0; i < trackingFaces.Size(); i++) { int key = trackingFaces.KeyAt(i); TrackedModel face = trackingFaces.Get(key); if (!currentFrame.Contains(face)) { leftFaces.Add(key); } else { if (onTrackListener != null) { face.setFrame(frame); onTrackListener.onTrack(face); } } } foreach (int?key in leftFaces) { TrackedModel left = trackingFaces.Get(key.Value); Log.Info("xx", " left:" + left); left.setEvent(Event.OnLeave); trackingFaces.Remove(key.Value); if (onTrackListener != null) { onTrackListener.onTrack(left); } // TODO release argb? } }
public void RemoveData(DataAccessor accessor) { if (ContainsData(accessor) == false) { throw new NoSuchDataException(this, accessor); } // If the data is being added, then just remove it. Otherwise, add to to the removed // collection. if (_data[accessor.Id].WasAdded) { _data.Remove(accessor.Id); } else { _data[accessor.Id].WasRemoved = true; } }
private void ShowRow(int row, bool removeFromList) { VisibilityHandler.Row hiddenRow = mHideRowList.Get(row); if (hiddenRow != null) { // add row model to the adapter mTableView.GetAdapter().AddRow(row, (Adapter.IRowHeader)hiddenRow.GetRowHeaderModel(), (IList <Adapter.ICell>)hiddenRow.GetCellModelList()); } else { Log.Error(LogTag, "This row is already visible."); } if (removeFromList) { mHideRowList.Remove(row); } }
private void ShowColumn(int column, bool removeFromList) { VisibilityHandler.Column hiddenColumn = mHideColumnList.Get(column); if (hiddenColumn != null) { // add column model to the adapter mTableView.GetAdapter().AddColumn(column, (Adapter.IColumnHeader)hiddenColumn.GetColumnHeaderModel(), (IList <Adapter.ICell>)hiddenColumn.GetCellModelList()); } else { Log.Error(LogTag, "This column is already visible."); } if (removeFromList) { mHideColumnList.Remove(column); } }
public override void DestroyItem(View container, int position, Object objectValue) { base.DestroyItem(container, position, objectValue); mPageReferenceMap.Remove(position); }
public virtual void Uproot(int pos) { plants.Remove(pos); }
public override void DestroyItem(ViewGroup container, int position, Object objectValue) { base.DestroyItem(container, position, objectValue); _registeredFragment.Remove(position); }
// Unregister when the item is inactive public override void DestroyItem(ViewGroup container, int position, Java.Lang.Object @object) { registeredFragments.Remove(position); base.DestroyItem(container, position, @object); }
public override void DestroyItem(Android.Views.ViewGroup container, int position, Java.Lang.Object objectValue) { registeredFragments.Remove(position); base.DestroyItem(container, position, objectValue); }
/// <summary> /// Remove the given type of data from the template instance. New instances will not longer /// have this added to the template. /// </summary> /// <remarks> /// If the ITemplate is currently being backed by an IGameEngine, this will throw an /// InvalidOperationException. /// </remarks> /// <param name="accessor">The type of data to remove.</param> /// <returns>True if the data was removed.</returns> public bool RemoveDefaultData(DataAccessor accessor) { return(_defaultDataInstances.Remove(accessor.Id)); }