System.Collections.Generic.IList.RemoveAt(int)

Here are the examples of the csharp api System.Collections.Generic.IList.RemoveAt(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

657 Examples 7

19 Source : NullFreeList.cs
with MIT License
from dolittle

public void RemoveAt(int index)
        {
            _elements.RemoveAt(index);
        }

19 Source : XmlDataCollection.cs
with MIT License
from dotnet

internal void SynchronizeCollection(XmlNodeList nodes)
        {
            if (nodes == null)
            {
                Items.Clear();
                return;
            }

            int i = 0, j;
            while (i < this.Count && i < nodes.Count)
            {
                if (this[i] != nodes[i])
                {
                    // starting after current node, see if the old node is still in the new list.
                    for (j = i + 1; j < nodes.Count; ++j)
                    {
                        if (this[i] == nodes[j])
                        {
                            break;
                        }
                    }
                    if (j < nodes.Count)
                    {
                        // the node from existing collection is found at [j] in the new collection;
                        // this means the node(s) [i ~ j-1] in new collection should be inserted.
                        while (i < j)
                        {
                            Items.Insert(i, nodes[i]);
                            ++i;
                        }
                        ++i; // advance to next node
                    }
                    else
                    {
                        // the node from existing collection is no longer in
                        // the new collection, delete it.
                        Items.RemoveAt(i);

                        // do not advance to the next node
                    }
                }
                else
                {
                    // nodes are the same; advance to the next node.
                    ++i;
                }
            }
            // Remove any extra nodes left over in the old collection
            while (i < this.Count)
            {
                Items.RemoveAt(i);
            }
            // Add any extra new nodes from the new collection
            while (i < nodes.Count)
            {
                Items.Insert(i, nodes[i]);
                ++i;
            }
        }

19 Source : ListExtensions.cs
with MIT License
from dotnet-toolbelt

public static void RemoveFirst<T>(this IList<T> list)
        {
            if (list.Count > 0)
            {
                list.RemoveAt(0);
            }
        }

19 Source : ListExtensions.cs
with MIT License
from dotnet-toolbelt

public static void RemoveLast<T>(this IList<T> source, int n = 1)
        {
            for (int i = 0; i < n; i++)
            {
                source.RemoveAt(source.Count - 1);
            }
        }

19 Source : ListExtensions.cs
with MIT License
from dotnet-toolbelt

public static void Replace<T>(this IList<T> @this, T oldValue, T newValue)
        {
            var oldIndex = @this.IndexOf(oldValue);
            while (oldIndex > 0)
            {
                @this.RemoveAt(oldIndex);
                @this.Insert(oldIndex, newValue);
                oldIndex = @this.IndexOf(oldValue);
            }
        }

19 Source : ListExtensions.cs
with MIT License
from dotnet-toolbelt

public static bool Replace<T>(this IList<T> thisList, int position, T item)
        {
            if (position > thisList.Count - 1)
                return false;
            thisList.RemoveAt(position);
            thisList.Insert(position, item);
            return true;
        }

19 Source : ListWrapper.cs
with GNU Lesser General Public License v3.0
from dotnettools

public void RemoveAt(int index)
            => _list.RemoveAt(index);

19 Source : MixedCodeDocumentFragmentList.cs
with GNU General Public License v3.0
from DSorlov

public void RemoveAt(int index)
        {
            //MixedCodeDoreplacedentFragment frag = (MixedCodeDoreplacedentFragment) _items[index];
            _items.RemoveAt(index);
        }

19 Source : WordPOSTagger.cs
with MIT License
from ebenso

private static IList<Tuple<string, string>> GetFilteredTokens(IList<Tuple<string, string>> taggedTokens)
        {
            for (int i = taggedTokens.Count - 1; i >= 0; i--)
            {
                if (RequiredTags.All(x => x != taggedTokens[i].Item2))
                {
                    taggedTokens.RemoveAt(i);
                }
            }
            return taggedTokens;
        }

19 Source : ShaderPreprocessor.cs
with MIT License
from ecidevilin

public void OnProcessShader(Shader shader, ShaderSnippetData snippetData, IList<ShaderCompilerData> compilerDataList)
        {
            LightweightRenderPipelinereplacedet lwrpreplacedet = GraphicsSettings.renderPipelinereplacedet as LightweightRenderPipelinereplacedet;
            if (lwrpreplacedet == null || compilerDataList == null || compilerDataList.Count == 0)
                return;

            ShaderFeatures features = GetSupportedShaderFeatures(lwrpreplacedet);

            int prevVariantCount = compilerDataList.Count;

            for (int i = 0; i < compilerDataList.Count; ++i)
            {
                if (StripUnused(features, shader, snippetData, compilerDataList[i]))
                {
                    compilerDataList.RemoveAt(i);
                    --i;
                }
            }

            if (lwrpreplacedet.shaderVariantLogLevel != ShaderVariantLogLevel.Disabled)
            {
                m_TotalVariantsInputCount += prevVariantCount;
                m_TotalVariantsOutputCount += compilerDataList.Count;
                LogShaderVariants(shader, snippetData, lwrpreplacedet.shaderVariantLogLevel, prevVariantCount, compilerDataList.Count);
            }
        }

19 Source : JContainer.cs
with Apache License 2.0
from elastic

internal virtual void RemoveItemAt(int index)
		{
			var children = ChildrenTokens;

			if (index < 0) throw new ArgumentOutOfRangeException(nameof(index), "Index is less than 0.");

			if (index >= children.Count) throw new ArgumentOutOfRangeException(nameof(index), "Index is equal to or greater than Count.");

			CheckReentrancy();

			var item = children[index];
			var previous = index == 0 ? null : children[index - 1];
			var next = index == children.Count - 1 ? null : children[index + 1];

			if (previous != null) previous.Next = next;
			if (next != null) next.Previous = previous;

			item.Parent = null;
			item.Previous = null;
			item.Next = null;

			children.RemoveAt(index);

#if HAVE_COMPONENT_MODEL
            if (_listChanged != null)
            {
                OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
            }
#endif
#if HAVE_INOTIFY_COLLECTION_CHANGED
            if (_collectionChanged != null)
            {
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index));
            }
#endif
		}

19 Source : JsonSchemaBuilder.cs
with Apache License 2.0
from elastic

private JsonSchema Pop()
		{
			var poppedSchema = CurrentSchema;
			_stack.RemoveAt(_stack.Count - 1);
			CurrentSchema = _stack.LastOrDefault();

			return poppedSchema;
		}

19 Source : JsonSchemaGenerator.cs
with Apache License 2.0
from elastic

private TypeSchema Pop()
		{
			var popped = _stack[_stack.Count - 1];
			_stack.RemoveAt(_stack.Count - 1);
			var newValue = _stack.LastOrDefault();
			if (newValue != null)
				CurrentSchema = newValue.Schema;
			else
				CurrentSchema = null;

			return popped;
		}

19 Source : XunitConsoleForwarder.cs
with MIT License
from elsa-workflows

private void FlushLine()
        {
            if (_line.Count > 0 && _line.Last() == '\r')
                _line.RemoveAt(_line.Count - 1);

            _output.WriteLine(new string(_line.ToArray()));
        }

19 Source : LoanApiObject.cs
with MIT License
from EncompassRest

private void DeleteFromLoanObject(string id)
        {
            var list = GetInLoan(LoanObjectBoundApis!.Loan);
            var index = list.IndexOf(id);
            if (index >= 0)
            {
                list.RemoveAt(index);
            }
        }

19 Source : RenumberGridsAdvUI.xaml.cs
with MIT License
from engthiago

private void gridGrids_Drop(object sender, DragEventArgs e)
        {
            if (rowIndex < 0)
                return;
            int index = GetCurrentRowIndex(e.GetPosition);
            if (index < 0)
                return;
            if (index == rowIndex)
                return;
            if (index >= gridGrids.Items.Count - 1)
            {
                return;
            }
            //IList<DataGridCellInfo> productCollection = gridGrids.SelectedCells;
            //DataGridCellInfo changedProduct = productCollection[rowIndex];


            if (rowIndex > (gridGrids.Items.Count - 1))
                return;

            try
            {
                DataGridCellInfo changedProduct = gridGrids.SelectedCells[0];

                GridInfo changedInfo = changedProduct.Item as GridInfo;

                gridInfoList.RemoveAt(rowIndex);
                gridInfoList.Insert(index, changedInfo);

                PopulateGrids();
            }
            catch
            {
            }
        }

19 Source : ElementsJoinUIAdvanced.xaml.cs
with MIT License
from engthiago

private void comboLowerLevel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboLowerLevel.HasItems)
            {
                selectedLowerLevel = (comboLowerLevel.Items.GereplacedemAt(comboLowerLevel.SelectedIndex) as LevelInfo).levelId;

                IList<LevelInfo> currentLevelsAboveSelectedLowerLevel = LevelInfoList.ToList();
                if (comboLowerLevel.SelectedIndex != 0)
                {
                    for (int i = comboLowerLevel.SelectedIndex -1; i >= 0; i--)
                    {
                        currentLevelsAboveSelectedLowerLevel.RemoveAt(i);
                    }

                    PopulateComboLevel(comboUpperLevel, currentLevelsAboveSelectedLowerLevel, true); 
                }else
                {
                    PopulateComboLevel(comboUpperLevel, LevelInfoList, true);
                }

            }
        }

19 Source : ElementsJoinUIAdvanced.xaml.cs
with MIT License
from engthiago

private void lowerLevel_Loaded(object sender, RoutedEventArgs e)
        {
            //Removes the last option (it will be above last level, see constructor)
            IList<LevelInfo> currentLevelListWithoutLast = LevelInfoList.ToList();
            if (currentLevelListWithoutLast.Count > 0)
            {
                currentLevelListWithoutLast.RemoveAt(currentLevelListWithoutLast.Count - 1);
                PopulateComboLevel(comboLowerLevel, currentLevelListWithoutLast); 
            }
        }

19 Source : ObservableCollection.cs
with Apache License 2.0
from epam-cross-platform-lab

public void RemoveRange(int index, int count)
        {
            CheckReentrancy();

            var startIndex = index;
            var currentIndex = startIndex;
            var endIndex = startIndex + count;
            var existingItems = Items;
            var removedItems = new List<replacedem>();

            while (currentIndex < endIndex)
            {
                removedItems.Add(existingItems[startIndex]);
                existingItems.RemoveAt(startIndex);

                currentIndex++;
            }

            OnPropertyChanged(new PropertyChangedEventArgs(CountString));
            OnPropertyChanged(new PropertyChangedEventArgs(IndexerName));
            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, removedItems, startIndex));
        }

19 Source : Utils.cs
with MIT License
from erdomke

public static void RemoveByFilter<T>(this IList<T> list, Func<T, bool> predicate)
    {
      var i = 0;
      while (i < list.Count)
      {
        if (predicate(list[i]))
          list.RemoveAt(i);
        else
          i++;
      }
    }

19 Source : PerFlowLifecycleWeaver.cs
with MIT License
from erhan0

private void SplitInstructions()
        {
            affectedInstructions = il.Body.Instructions.ToList();
            il.Body.Instructions.Clear();

            if(instruction == null)
            {
                var first = affectedInstructions.First();
                var last = affectedInstructions.Last(x=> x.OpCode == OpCodes.Ret);
                
                if (first.OpCode == OpCodes.Nop)
                {
                    beforeInstructions.Add(first);
                    affectedInstructions.RemoveAt(0);
                }
                if(last.OpCode == OpCodes.Ret)
                {
                    afterInstructions.Add(last);
                    affectedInstructions.Remove(last);
                }
            }
            else
            {
                var index = affectedInstructions.IndexOf(instruction);
                beforeInstructions = affectedInstructions.Take(index).ToList();
                afterInstructions = affectedInstructions.Skip(index + 1).ToList();

                affectedInstructions.Clear();
                foreach (var argLoc in iDescriptor.ArgTypes.Select(argType => method.AddLocal(argType)).Reverse())
                {
                    beforeInstructions.Add(il.Create(OpCodes.Stloc, argLoc));
                    affectedInstructions.Insert(0, il.Create(OpCodes.Ldloc, argLoc));
                }
                var targetType = iDescriptor.TargetType;
                if(targetType != null)
                {
                    var targetLoc = method.AddLocal(targetType);
                    beforeInstructions.Add(il.Create(OpCodes.Stloc, targetLoc));
                    affectedInstructions.Insert(0, il.Create(OpCodes.Ldloc, targetLoc));
                }
                
                affectedInstructions.Add(instruction);
            }

            var retType = GetReturnType();
            if (retType != null)
            {
                var retVal = method.AddLocal(retType);
                affectedInstructions.Add(il.Create(OpCodes.Stloc, retVal));
                afterInstructions.Insert(0, il.Create(OpCodes.Ldloc, retVal));
            }
            
        }

19 Source : TLVector.cs
with GNU General Public License v2.0
from evgeny-nadymov

public void RemoveAt(int index)
        {
            Items.RemoveAt(index);
        }

19 Source : DecryptedImageViewerViewModel.cs
with GNU General Public License v2.0
from evgeny-nadymov

public void Delete()
        {
            if (Currenreplacedem == null) return;
            if (DialogDetails == null) return;

            var currenreplacedem = Currenreplacedem;
            DialogDetails.DeleteMessageWithCallback(true, (TLDecryptedMessage) Currenreplacedem,
                () => Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.1), () =>
                {
                    if (CanSlideRight)
                    {
                        var view = GetView() as DecryptedImageViewerView;
                        if (view != null)
                        {
                            _items.RemoveAt(_currentIndex--);
                            view.SlideRight(0.0, () =>
                            {
                                view.SetControlContent(2, Nexreplacedem);
                                GroupedItems.Remove(currenreplacedem);
                            });
                        }
                    }
                    else if (CanSlideLeft)
                    {
                        var view = GetView() as DecryptedImageViewerView;
                        if (view != null)
                        {
                            _items.RemoveAt(_currentIndex);
                            view.SlideLeft(0.0, () =>
                            {
                                view.SetControlContent(0, PreviousItem);
                                GroupedItems.Remove(currenreplacedem);
                            });
                        }
                    }
                    else
                    {
                        Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.25), CloseViewer);
                    }
                }));
        }

19 Source : SecretDialogDetailsViewModel.Reply.cs
with GNU General Public License v2.0
from evgeny-nadymov

private static TLDecryptedMessage ReplaceWithGroup(IList<TLDecryptedMessageBase> messages, int position, int length)
        {
            var message = messages[position + length - 1] as TLDecryptedMessage73;
            if (message != null)
            {
                var group = new TLVector<TLDecryptedMessageBase>();
                for (var i = 0; i < length; i++)
                {
                    group.Insert(0, messages[position]);
                    messages.RemoveAt(position);
                }

                var mediaGroup = new TLDecryptedMessageMediaGroup { Group = group };

                var groupedMessage = new TLDecryptedMessage73
                {
                    Flags = new TLInt(0),
                    Out = message.Out,
                    Unread = message.Unread,
                    RandomId = message.RandomId,
                    FromId = message.FromId,
                    //ToId = message.ToId,
                    //FwdHeader = message.FwdHeader,
                    ViaBotName = message.ViaBotName,
                    ReplyToRandomMsgId = message.ReplyToRandomMsgId,
                    Date = message.Date,
                    TTL = new TLInt(0), //message.TTL,
                    Message = TLString.Empty,
                    Media = mediaGroup,
                    //ReplyMarkup = message.ReplyMarkup,
                    Enreplacedies = new TLVector<TLMessageEnreplacedyBase>(),
                    //Views = message.Views,
                    //EditDate = message.EditDate,
                    //PostAuthor = message.PostAuthor,
                    GroupedId = message.GroupedId,
                    Status = message.Status
                };

                //if (groupedMessage.FromId != null) groupedMessage.SetFromId();
                if (groupedMessage.Media != null) groupedMessage.SetMedia();

                messages.Insert(position, groupedMessage);

                return groupedMessage;
            }

            return null;
        }

19 Source : ImageViewerViewModel.cs
with GNU General Public License v2.0
from evgeny-nadymov

public void Delete()
        {
            if (Currenreplacedem == null) return;
            if (DialogDetails == null) return;

            var currenreplacedem = Currenreplacedem;
            DialogDetails.DeleteMessageById(
                currenreplacedem, 
                () =>
                {
                    Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.1), () =>
                    {
                        if (CanSlideRight)
                        {
                            var view = GetView() as ImageViewerView;
                            if (view != null)
                            {
                                _items.RemoveAt(_currentIndex--);
                                view.SlideRight(0.0, () =>
                                {
                                    view.SetControlContent(2, Nexreplacedem);
                                    GroupedItems.Remove(currenreplacedem);
                                });
                            }
                        }
                        else if (CanSlideLeft)
                        {
                            var view = GetView() as ImageViewerView;
                            if (view != null)
                            {
                                _items.RemoveAt(_currentIndex);
                                view.SlideLeft(0.0, () =>
                                {
                                    view.SetControlContent(0, PreviousItem);
                                    GroupedItems.Remove(currenreplacedem);
                                });
                            }
                        }
                        else
                        {
                            Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.25), CloseViewer);
                        }
                    });
                });
        }

19 Source : ProfilePhotoViewerViewModel.cs
with GNU General Public License v2.0
from evgeny-nadymov

public void DeletePhoto()
        {
            if (_currentContact == null || !_currentContact.IsSelf) return;
            if (Currenreplacedem == null) return;

            var currenreplacedem = Currenreplacedem;
            IsWorking = true;
            MTProtoService.UpdateProfilePhotoAsync(new TLInputPhotoEmpty(),
                result =>
                {
                    Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.1), () =>
                    {
                        IsWorking = false;

                        if (CanSlideLeft)
                        {
                            var view = GetView() as ProfilePhotoViewerView;
                            if (view != null)
                            {
                                _items.RemoveAt(_currentIndex--);
                                view.SlideLeft(0.0, () =>
                                {
                                    view.SetControlContent(0, PreviousItem);
                                    GroupedItems.Remove(currenreplacedem);
                                });
                            }
                        }
                        else
                        {
                            Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.25), CloseViewer);
                        }
                    });
                },
                error =>
                {
                    IsWorking = false;
                    Execute.ShowDebugMessage("photos.updateProfilePhoto error " + error);
                });
        }

19 Source : ProfilePhotoViewerViewModel.cs
with GNU General Public License v2.0
from evgeny-nadymov

public void SetPhoto()
        {
            var photo = Currenreplacedem as TLPhoto;
            if (photo == null) return;

            TLPhotoSize size = null;
            var sizes = photo.Sizes.OfType<TLPhotoSize>();
            const double width = 800.0;
            foreach (var photoSize in sizes)
            {
                if (size == null
                    || Math.Abs(width - size.W.Value) > Math.Abs(width - photoSize.W.Value))
                {
                    size = photoSize;
                }
            }
            if (size == null) return;

            var location = size.Location as TLFileLocation;
            if (location == null) return;

            if (_currentContact != null)
            {
                IsWorking = true;
                MTProtoService.UpdateProfilePhotoAsync(new TLInputPhoto { Id = photo.Id, AccessHash = photo.AccessHash },
                    result =>
                    {
                        IsWorking = false;
                        _items.Insert(0, result);
                        _currentIndex++;
                        MTProtoService.GetUserPhotosAsync(_currentContact.ToInputUser(), new TLInt(1), new TLLong(0), new TLInt(1),
                            photos =>
                            {
                                var previousPhoto = photos.Photos.FirstOrDefault();

                                if (previousPhoto != null)
                                {
                                    _items.RemoveAt(1);
                                    _items.Insert(1, previousPhoto);
                                }
                            },
                            error =>
                            {
                                Execute.ShowDebugMessage("photos.getUserPhotos error " + error);
                            });
                    },
                    error =>
                    {
                        IsWorking = false;
                        Execute.ShowDebugMessage("photos.updateProfilePhoto error " + error);
                    });
            }
            else if (_currentChat != null)
            {

                var channel = _currentChat as TLChannel;
                if (channel != null)
                {
                    if (channel.Id != null)
                    {
                        IsWorking = true;
                        MTProtoService.EditPhotoAsync(
                            channel,
                            new TLInputChatPhoto56
                            {
                                Id = new TLInputPhoto { Id = photo.Id, AccessHash = photo.AccessHash }
                            },
                            result => Execute.BeginOnUIThread(() =>
                            {
                                IsWorking = false;
                                var updates = result as TLUpdates;
                                if (updates != null)
                                {
                                    var updateNewMessage = updates.Updates.FirstOrDefault(x => x is TLUpdateNewMessage) as TLUpdateNewMessage;
                                    if (updateNewMessage != null)
                                    {
                                        var serviceMessage = updateNewMessage.Message as TLMessageService;
                                        if (serviceMessage != null)
                                        {
                                            var chatEditPhotoAction = serviceMessage.Action as TLMessageActionChatEditPhoto;
                                            if (chatEditPhotoAction != null)
                                            {
                                                var newPhoto = chatEditPhotoAction.Photo as TLPhoto;
                                                if (newPhoto != null)
                                                {
                                                    _items.Insert(0, newPhoto);
                                                    _currentIndex++;
                                                }
                                            }
                                        }
                                    }
                                }
                            }),
                            error => Execute.BeginOnUIThread(() =>
                            {
                                IsWorking = false;
                                Execute.ShowDebugMessage("messages.editChatPhoto error " + error);
                            }));
                    }
                }

                var chat = _currentChat as TLChat;
                if (chat != null)
                {
                    IsWorking = true;
                    MTProtoService.EditChatPhotoAsync(
                        chat.Id,
                        new TLInputChatPhoto56
                        {
                            Id = new TLInputPhoto { Id = photo.Id, AccessHash = photo.AccessHash }
                        },
                        result => Execute.BeginOnUIThread(() =>
                        {
                            IsWorking = false;
                            var updates = result as TLUpdates;
                            if (updates != null)
                            {
                                var updateNewMessage = updates.Updates.FirstOrDefault(x => x is TLUpdateNewMessage) as TLUpdateNewMessage;
                                if (updateNewMessage != null)
                                {
                                    var serviceMessage = updateNewMessage.Message as TLMessageService;
                                    if (serviceMessage != null)
                                    {
                                        var chatEditPhotoAction = serviceMessage.Action as TLMessageActionChatEditPhoto;
                                        if (chatEditPhotoAction != null)
                                        {
                                            var newPhoto = chatEditPhotoAction.Photo as TLPhoto;
                                            if (newPhoto != null)
                                            {
                                                _items.Insert(0, newPhoto);
                                                _currentIndex++;
                                            }
                                        }
                                    }
                                }
                            }
                        }),
                        error => Execute.BeginOnUIThread(() =>
                        {
                            IsWorking = false;
                            Execute.ShowDebugMessage("messages.editChatPhoto error " + error);
                        }));
                }
            }
        }

19 Source : MethodEditor.cs
with MIT License
from exys228

public void RemoveAt(int index, int count = 1)
		{
			for (int i = 0; i < count && index < Count; i++)
				Instrs.RemoveAt(index);

			ClampPosition();
		}

19 Source : NodeList.cs
with GNU General Public License v3.0
from F1uctus

void IList<T>.RemoveAt(int index) {
            items.RemoveAt(index);
        }

19 Source : FormExtensions.cs
with MIT License
from fahminlb33

public static void SwapItem<T>(this IList<T> list, Predicate<T> predicate, T item)
        {
            var index = FindIndex(list, predicate);
            list.RemoveAt(index);
            list.Insert(index, item);
        }

19 Source : OrderByRewriter.cs
with GNU General Public License v3.0
from faib920

protected void PrependOrderings(IList<OrderExpression> newOrderings)
        {
            if (newOrderings != null)
            {
                if (this.gatheredOrderings == null)
                {
                    this.gatheredOrderings = new List<OrderExpression>();
                }
                for (int i = newOrderings.Count - 1; i >= 0; i--)
                {
                    this.gatheredOrderings.Insert(0, newOrderings[i]);
                }
                // trim off obvious duplicates
                HashSet<string> unique = new HashSet<string>();
                for (int i = 0; i < this.gatheredOrderings.Count; )
                {
                    ColumnExpression column = this.gatheredOrderings[i].Expression as ColumnExpression;
                    if (column != null)
                    {
                        string hash = column.Alias + ":" + column.Name;
                        if (unique.Contains(hash))
                        {
                            this.gatheredOrderings.RemoveAt(i);
                            // don't increment 'i', just continue
                            continue;
                        }
                        else
                        {
                            unique.Add(hash);
                        }
                    }
                    i++;
                }
            }
        }

19 Source : OrderByRewriter.cs
with GNU Lesser General Public License v3.0
from faib920

protected void PrependOrderings(IList<OrderExpression> newOrderings)
        {
            if (newOrderings != null)
            {
                if (_gatheredOrderings == null)
                {
                    _gatheredOrderings = new List<OrderExpression>();
                }
                for (int i = newOrderings.Count - 1; i >= 0; i--)
                {
                    _gatheredOrderings.Insert(0, newOrderings[i]);
                }
                // trim off obvious duplicates
                HashSet<string> unique = new HashSet<string>();
                for (int i = 0; i < _gatheredOrderings.Count;)
                {
                    ColumnExpression column = _gatheredOrderings[i].Expression as ColumnExpression;
                    if (column != null)
                    {
                        string hash = column.Alias + ":" + column.Name;
                        if (unique.Contains(hash))
                        {
                            _gatheredOrderings.RemoveAt(i);
                            // don't increment 'i', just continue
                            continue;
                        }
                        else
                        {
                            unique.Add(hash);
                        }
                    }
                    i++;
                }
            }
        }

19 Source : ListUtility.cs
with MIT License
from Faithlife

public static int RemoveWhere<T>(this IList<T> list, Func<T, bool> predicate)
		{
			// check arguments
			if (list is null)
				throw new ArgumentNullException(nameof(list));
			if (predicate is null)
				throw new ArgumentNullException(nameof(predicate));

			// remove items that match
			var originalCount = list.Count;
			var count = originalCount;
			var index = 0;
			while (index < count)
			{
				if (predicate(list[index]))
				{
					list.RemoveAt(index);
					count--;
				}
				else
				{
					index++;
				}
			}

			return originalCount - count;
		}

19 Source : RichTextAreaSink.cs
with GNU General Public License v3.0
from FanTranslatorsInternational

private void LogInternal(Color logColor, string message)
        {
            var text = message + '\n';

            // Cap log if necessary
            if (_loggedPositions.Count > _limit)
            {
                _richTextArea.Buffer.Delete(new Range<int>(_loggedPositions[0], _loggedLengths[0] - 1));

                var firstLength = _loggedLengths[0];
                _loggedPositions.RemoveAt(0);
                _loggedLengths.RemoveAt(0);

                for (var i = 0; i < _loggedPositions.Count; i++)
                    _loggedPositions[i] -= firstLength;
            }

            // Update text buffer
            var position = _loggedPositions.Count <= 0 ? 0 : _loggedPositions.Last() + _loggedLengths.Last();
            _loggedPositions.Add(position);

            _richTextArea.Buffer.Insert(position, text);
            _loggedLengths.Add(_richTextArea.Text.Length - position - 1);

            _richTextArea.Buffer.SetForeground(new Range<int>(position, _richTextArea.Text.Length - 1), logColor);
        }

19 Source : SupportClass.cs
with MIT License
from FastReports

public static void SetCapacity<T>(System.Collections.Generic.IList<T> vector, int newCapacity) where T : new()
      {
         while (newCapacity > vector.Count)
            vector.Add(new T());
         while (newCapacity < vector.Count)
            vector.RemoveAt(vector.Count - 1);
      }

19 Source : ListPoolAsIListOfTSourceTests.cs
with MIT License
from faustodavid

public override void RemoveAt_when_item_exists_remove_item_and_decrease_itemsCount()
        {
            const int expectedCountAfterRemove = 2;
            int expectedAt1 = s_fixture.Create<int>();
            using ListPool<int> listPool = new ListPool<int>(3) {s_fixture.Create<int>(), expectedAt1, s_fixture.Create<int>()};
            IList<int> sut = listPool;

            sut.RemoveAt(1);

            replacedert.DoesNotContain(expectedAt1, sut);
            replacedert.Equal(expectedCountAfterRemove, sut.Count);
        }

19 Source : ListPoolAsIListOfTSourceTests.cs
with MIT License
from faustodavid

public override void RemoveAt_with_index_above_itemsCount_throws_IndexOutOfRangeException()
        {
            const int index = 2;
            using ListPool<int> listPool = new ListPool<int> {s_fixture.Create<int>()};
            IList<int> sut = listPool;

            replacedert.Throws<IndexOutOfRangeException>(() => sut.RemoveAt(index));
        }

19 Source : ListPoolAsIListOfTSourceTests.cs
with MIT License
from faustodavid

public override void RemoveAt_with_index_bellow_zero_throws_ArgumentOutOfRangeException()
        {
            const int index = -1;
            using ListPool<int> listPool = new ListPool<int>();
            IList<int> sut = listPool;

            replacedert.Throws<ArgumentOutOfRangeException>(() => sut.RemoveAt(index));
        }

19 Source : ListPoolAsIListOfTSourceTests.cs
with MIT License
from faustodavid

public override void RemoveAt_with_index_zero_when_not_item_added_throws_IndexOutOfRangeException()
        {
            const int index = 0;
            using ListPool<int> listPool = new ListPool<int>();
            IList<int> sut = listPool;

            replacedert.Throws<IndexOutOfRangeException>(() => sut.RemoveAt(index));
        }

19 Source : Configuration.cs
with MIT License
from featherhttp

public void RemoveAt(int index)
            {
                _sources.RemoveAt(index);
                _sourcesModified();
            }

19 Source : SyncList.cs
with Apache License 2.0
from FieldWarning

public void RemoveAt(int index)
        {
            T oldItem = objects[index];
            objects.RemoveAt(index);
            AddOperation(Operation.OP_REMOVEAT, index, oldItem, default);
        }

19 Source : SyncList.cs
with Apache License 2.0
from FieldWarning

public void OnDeserializeDelta(NetworkReader reader)
        {
            // This list can now only be modified by synchronization
            IsReadOnly = true;

            int changesCount = (int)reader.ReadUInt32();

            for (int i = 0; i < changesCount; i++)
            {
                Operation operation = (Operation)reader.ReadByte();

                // apply the operation only if it is a new change
                // that we have not applied yet
                bool apply = changesAhead == 0;
                int index = 0;
                T oldItem = default;
                T newItem = default;

                switch (operation)
                {
                    case Operation.OP_ADD:
                        newItem = reader.Read<T>();
                        if (apply)
                        {
                            index = objects.Count;
                            objects.Add(newItem);
                        }
                        break;

                    case Operation.OP_CLEAR:
                        if (apply)
                        {
                            objects.Clear();
                        }
                        break;

                    case Operation.OP_INSERT:
                        index = (int)reader.ReadUInt32();
                        newItem = reader.Read<T>();
                        if (apply)
                        {
                            objects.Insert(index, newItem);
                        }
                        break;

                    case Operation.OP_REMOVEAT:
                        index = (int)reader.ReadUInt32();
                        if (apply)
                        {
                            oldItem = objects[index];
                            objects.RemoveAt(index);
                        }
                        break;

                    case Operation.OP_SET:
                        index = (int)reader.ReadUInt32();
                        newItem = reader.Read<T>();
                        if (apply)
                        {
                            oldItem = objects[index];
                            objects[index] = newItem;
                        }
                        break;
                }

                if (apply)
                {
                    Callback?.Invoke(operation, index, oldItem, newItem);
                }
                // we just skipped this change
                else
                {
                    changesAhead--;
                }
            }
        }

19 Source : SyncList.cs
with Mozilla Public License 2.0
from finol-digital

public void OnDeserializeDelta(NetworkReader reader)
        {
            // This list can now only be modified by synchronization
            IsReadOnly = true;

            int changesCount = (int)reader.ReadUInt();

            for (int i = 0; i < changesCount; i++)
            {
                Operation operation = (Operation)reader.ReadByte();

                // apply the operation only if it is a new change
                // that we have not applied yet
                bool apply = changesAhead == 0;
                int index = 0;
                T oldItem = default;
                T newItem = default;

                switch (operation)
                {
                    case Operation.OP_ADD:
                        newItem = reader.Read<T>();
                        if (apply)
                        {
                            index = objects.Count;
                            objects.Add(newItem);
                        }
                        break;

                    case Operation.OP_CLEAR:
                        if (apply)
                        {
                            objects.Clear();
                        }
                        break;

                    case Operation.OP_INSERT:
                        index = (int)reader.ReadUInt();
                        newItem = reader.Read<T>();
                        if (apply)
                        {
                            objects.Insert(index, newItem);
                        }
                        break;

                    case Operation.OP_REMOVEAT:
                        index = (int)reader.ReadUInt();
                        if (apply)
                        {
                            oldItem = objects[index];
                            objects.RemoveAt(index);
                        }
                        break;

                    case Operation.OP_SET:
                        index = (int)reader.ReadUInt();
                        newItem = reader.Read<T>();
                        if (apply)
                        {
                            oldItem = objects[index];
                            objects[index] = newItem;
                        }
                        break;
                }

                if (apply)
                {
                    Callback?.Invoke(operation, index, oldItem, newItem);
                }
                // we just skipped this change
                else
                {
                    changesAhead--;
                }
            }
        }

19 Source : EnumLookupTable.cs
with BSD 3-Clause "New" or "Revised" License
from FireFox2000000

public void RemoveAt(int index)
        {
            ((IList<Value>)table).RemoveAt(index);
        }

19 Source : SongObjectHelper.cs
with BSD 3-Clause "New" or "Revised" License
from FireFox2000000

public static bool Remove<T>(T item, IList<T> list, bool uniqueData = true) where T : SongObject
        {
            int pos = FindObjectPosition(item, list);

            if (pos != NOTFOUND)
            {
                if (uniqueData && item.GetType() == typeof(Note))
                {
                    // Update linked list
                    Note previous = FindPreviousOfType(item.GetType(), pos, list) as Note;
                    Note next = FindNextOfType(item.GetType(), pos, list) as Note;

                    if (previous != null)
                        previous.next = next;
                    if (next != null)
                        next.previous = previous;
                }
                list.RemoveAt(pos);

                return true;
            }

            return false;
        }

19 Source : ExtendedObservableCollection.cs
with MIT License
from FlaUI

public void RemoveAll(Predicate<T> match)
        {
            var removedItem = false;
            for (var i = Items.Count - 1; i >= 0; i--)
            {
                if (match(Items[i]))
                {
                    Items.RemoveAt(i);
                    removedItem = true;
                }
            }
            if (removedItem)
            {
                OnPropertyChanged(new PropertyChangedEventArgs("Count"));
                OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
            }
        }

19 Source : ExtendedObservableCollection.cs
with MIT License
from FlaUI

public void RemoveRange(int index, int count)
        {
            if (count <= 0 || index >= Items.Count) { return; }
            if (count == 1)
            {
                RemoveAt(index);
                return;
            }
            for (var i = 0; i < count; i++)
            {
                Items.RemoveAt(index);
            }
            OnPropertyChanged(new PropertyChangedEventArgs("Count"));
            OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
        }

19 Source : Sharpen.cs
with Apache License 2.0
from florinleon

public static T GetAndRemove<T>(this IList<T> list, int index)
        {
            T result = list[index];
            list.RemoveAt(index);
            return result;
        }

19 Source : Sharpen.cs
with Apache License 2.0
from florinleon

public static T RemoveAtReturningValue<T>(this IList<T> list, int index)
        {
            T value = list[index];
            list.RemoveAt(index);
            return value;
        }

19 Source : CollectionExtensions.cs
with MIT License
from framebunker

public static void FastRemoveAt<V> ([NotNull] this IList<V> source, int index)
		{
			int last = source.Count - 1;
			if (index < last)
			{
				source[index] = source[last];
			}

			source.RemoveAt (last);
		}

See More Examples