6 years later and the Framework still falls short of stuff that was so easy
SortedList: Definately not. FIFO order is not maintained.
Stack: Doesn't provide a way to remove duplicate values. Aside from
Come on... MRU is a simple concept. While my original post was detailed...
it's essentially very simple. Simply study how the Visual Studio MRU list in
the File menu works... or in any app for that matter. Traditionally you
accomplish it via either a lot of brute force array work... or slightly
collections in .NET but their case-sensitivity (I HATE THAT... not all
-C. Moya
"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:u7OKsYBRGHA.5924@TK2MSFTNGP09.phx.gbl...
> Carlos,
>
> I have not your problem complete in mind, however are you sure that the
> SortedList does not solve your problem. In your text is so much that is as
> well written in the description for this class. (I never have used it yet)
> You have an overloaded amount of questions so maybe can you do that with
> that class by inheriting it.
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionssortedlistclasstopic.asp
>
> Although your problem is majory sounds in my opinion a stack do I believe
> that you cannot use that or you should add very much to it.
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsstackclasstopic.asp
>
>
> I hope this helps something,
>
> Cor
>
> "CMM" <cmm@nospam.com> schreef in bericht
> news:ec$sXNBRGHA.4344@TK2MSFTNGP12.phx.gbl...
>> How so? I would agree if there was an alternative with all the same
>> features. So far, from what I have seen, there is NOT ONE framework-based
>> collection that does what VB-Collection does... as it is a hybrid of
>> Dictionary and List. Dictionary does not maintain FIFO order... and List
>> is not Keyed.
>>
>> Maybe I'm missing something? :-)
>>
>> Hey Cor... hotshot... solve the MRU problem. ;-)
>>
>> --
>> -C. Moya
>>
www.cmoya.com >> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
>> news:%23wgX56ARGHA.3916@TK2MSFTNGP11.phx.gbl...
>>> Carlos,
>>>
>>> Even Herfried agrees that the old VB collection should have been placed
>>> in the VB compatible namespace instead in the normal VB namespace. It
>>> should not been used. It is so much different from any other collection
>>> in Net (which AFAIK implements all ICollection) that it is embarrassing
>>> that the names are kept the same.
>>>
>>> Just my thought,
>>>
>>> Cor
>>>
>>> "CMM" <cmm@nospam.com> schreef in bericht
>>> news:OBJmtlARGHA.1728@TK2MSFTNGP11.phx.gbl...
>>>> Oh and the collection must be serializable (like, able to be stored in
>>>> My.Settings).
>>>>
>>>> Since the original post, I decided to just "forget about it" and go
>>>> with the intrinsic VB Collection object... only to find that it's not
>>>> serializable... so the values can't be stored in My.Settings. Sure, I
>>>> can write an algorithm to convert it... but, I'm looking for an easy
>>>> non-kludgy solution.
>>>>
>>>> --
>>>> -C. Moya
>>>>
www.cmoya.com >>>> "CMM" <cmm@nospam.com> wrote in message
>>>> news:OYvsC9%23QGHA.5500@TK2MSFTNGP12.phx.gbl...
>>>>> First let me say that maybe I'm having a "duh" moment and perhaps I'm
>>>>> missing something... but it seems to me that no one thing in the
>>>>> System.Collections namespace (even in .NET 2.0) even comes close to
>>>>> the still-useful-today VB intrinsic Collection. Here's the challenge
>>>>> (I know I'm totally missing something here)....
>>>>>
>>>>> Implement a full featured MRU (Most Recently Used) list using
>>>>> System.Collections.
>>>>>
>>>>> Use Case:
>>>>> 1) Current MRU: MyNotes.txt, MySpreadsheet1.txt, SomeOtherFile.txt
>>>>> 2) User opens "myspreadsheet1.txt" (note the case... the file was
>>>>> renamed sometime between step 1and2
>>>>> 3) New MRU: MyNotes.txt, SomeOtherFile.txt, *myspreadsheet1.txt*
>>>>>
>>>>> Requirements:
>>>>>
>>>>> 1) Items must be stored in their original case, but searches on the
>>>>> collection must be case-insensitive. No storing items using ToLower()
>>>>> cheating crap to work around the framework's case-sensitive
>>>>> collections.
>>>>>
>>>>> 2) Items must be stored oldest to newest (or newest to oldest... it
>>>>> doesn't really matter).
>>>>>
>>>>> 3) When adding a new item (case preserved), a matching item (case
>>>>> insensitive) already in the collection gets popped out.
>>>>> Well, Dictionary(Of String) seems to be the answer.... as the default
>>>>> comparator for Key is case-insensitive...
>>>>> MRUDictionary.Remove(file) <-- case insensitive
>>>>> MRUDictionary.Add(file, file) <-- new case preserved
>>>>>
>>>>> BUT...
>>>>>
>>>>> 4) The collection should allow access by index AND it must be
>>>>> "trimmable."
>>>>> Sub TrimMRU()
>>>>> If MRU.Count > 10 Then
>>>>> Dim delta As Integer = MRU.Count - 10
>>>>> For tally As Integer = 1 To delta
>>>>> MRU.RemoveAt(0) '<-- oldest items removed
>>>>> Next tally
>>>>> End If
>>>>> End Sub
>>>>> Dictionary does not support this. You cannot access items "by index."
>>>>>
>>>>> Anyone have an answer? This is easily done using "Collection"......
>>>>> but is there no "framework" equivalent without doing a lot of "kludgy"
>>>>> code?
>>>>>
>>>>> --
>>>>> -C. Moya
>>>>>
www.cmoya.com >>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>