Re: SortedList bug?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 10/14/04


Date: Thu, 14 Oct 2004 08:28:07 +0100

Jose Jarabo <JoseJarabo@discussions.microsoft.com> wrote:
> I am not sure how to categorize this, either a bug or something else but
> here is my problem.
>
> I am testing with 2 elements on a sorted list. If I remove the last element
> on the list everything works fine and I can add other elements to it. However
> if I remove the first element on the list and I try to add something then my
> first element is changed when I add a new element to that new element.
> Here is how im adding elements
>
> SomeDataType newlement = new SomeDataType();
> SomeSortedList[SomeSortedList.Count] = newelement;
>
> this is how I remove them.
>
> SomeSortedList.RemoveAt(index);
>
> I have reviewed the code over and over and the element is being correctly
> removed but apparently when the list is resorted a pointer to the element
> that moved to the empty spot remains in its original spot..
>
> Maybe im wrong and that hit i took to the head earlier has me spinning.
> Anyways if anyone can tell me.. please let me know.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • SortedList bug?
    ... I am not sure how to categorize this, either a bug or something else but ... first element is changed when I add a new element to that new element. ... SomeDataType newlement = new SomeDataType; ... that moved to the empty spot remains in its original spot.. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Problem with JCombo box
    ... vain, Can we solve this kind of bug? ... bug in the ComboBoxModel ... Here 2 nd combo box points to first element but the scroll bar of ... the combo box is not moving to first element. ...
    (comp.lang.java.programmer)
  • Re: Problem with JCombo box
    ... Maybe it's some bug in the ComboBoxModel ... Here 2 nd combo box points to first element but the scroll bar of ... the combo box is not moving to first element. ...
    (comp.lang.java.programmer)
  • Unifying lists
    ... The debugger showed me, that the first element of the first list is not pointed towards the first element of the second list as I try to do with the increment rule. ... Could anybody help me to fix this bug? ...
    (comp.lang.prolog)