473,326 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

need a collection that retains order and allows InsertAt(index) AND is accessible by key or index

dx
Any ideas? I can't find any examples that support this.

I'm thinking a solution may be something like inherting arraylist and
containing a hashtable.

or

Inheriting NameObjectCollectionBase and containing an arraylist to use for
looping thru in 'order'.
My current implementation display an inaccurate order, since the newly added
member is always appended to the end of the collection. Right now I'm
inheriting NameObjectCollectionBase, it seems to give meme everthing but
allowing me to InsertAt a specific location (therefore my order is wacked
when i enumerate.) The only potential solution I can think of for the
current implementation is to override the Add(), place all items in a
temporary contained collection, clear the class collection, and re-add using
some logic to add them in the appropriate order. I don't think this is a
good idea to clear the entire collection just to add a new item in an
appropriate order.

Thanks in advance for any ideas.

Stan

Nov 21 '05 #1
1 1072
dx,
Have you looked at System.Collections.SortedList? (Wrapping SortedList in a
class similar to CollectionBase).

Alternatively your Add method can either Sort the list after you added it or
you can do an Insertion sort (find the position in the list for the new item
& insert the item at the position. ArrayList.BinarySearch is useful for
this). Which of course requires an Insert method.

Hope this helps
Jay

"dx" <de*********@yahoo.com> wrote in message
news:bV****************@fe05.lga...
Any ideas? I can't find any examples that support this.

I'm thinking a solution may be something like inherting arraylist and
containing a hashtable.

or

Inheriting NameObjectCollectionBase and containing an arraylist to use for
looping thru in 'order'.
My current implementation display an inaccurate order, since the newly
added member is always appended to the end of the collection. Right now
I'm inheriting NameObjectCollectionBase, it seems to give meme everthing
but allowing me to InsertAt a specific location (therefore my order is
wacked when i enumerate.) The only potential solution I can think of for
the current implementation is to override the Add(), place all items in a
temporary contained collection, clear the class collection, and re-add
using some logic to add them in the appropriate order. I don't think this
is a good idea to clear the entire collection just to add a new item in an
appropriate order.

Thanks in advance for any ideas.

Stan

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dx | last post by:
I'd appreciate some ideas or direction with a collection issue. I need to create a custom collection that inherits ICollection, IEnumberable (need to be able to access by key, index and be able...
5
by: Michel | last post by:
Please how to identify the las item of an itemcollection without to scan all the collection.
1
by: dx | last post by:
Any ideas? I can't find any examples that support this. I'm thinking a solution may be something like inherting arraylist and containing a hashtable. or Inheriting NameObjectCollectionBase...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
2
by: Yuk Tang | last post by:
I've satisfactorily got an axwebbrowser control on a form within a panel, suitably positioned and sized, and now I want to display a webpage on it. This is not normally a problem when I have the...
5
by: gmccallum | last post by:
I am trying to create a base class that contains a collection that MUST be able to be referenced by both a string key and a positional index. This collection MUST keep the items in the same order...
7
by: Dale | last post by:
I have a design question. I am creating a custom collection of products. The unique key for the products is productId which is an integer. By default, IndexOf(object obj), when obj is an int,...
6
by: Burt | last post by:
I need to create a collection of classes (or structures) can be accessed by a string key, eg MyColl("ShortName5").Name for class with key ShortName5. But it also has to be sorted by a second...
0
by: G | last post by:
Hello friend, I am using a textbox with in a forloop, for each time when i click a button it genarates a new textbox, so for example for first time there will be 1 textbox, i will enter some...
3
by: jacob navia | last post by:
Abstract: Continuing the discussion about abstract data types, in this discussion group, a string collection data type is presented, patterned after the collection in C# and similar languages...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.