473,385 Members | 1,400 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,385 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 1558
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...
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...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.