473,836 Members | 1,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extended Sorted List

Hi !

I would like to make an array of structure (collection ?) that would
behave like an advanced sorted list : a sorted list with one key but
with multiple values (sorted lists are key/value items).

- indexed by value index or by key (2 indexers)
- sortable by key or a secondary key
- supporting foreach loops
Is there a class my 'ExtendedList' could inherit from that would make
the most part of the job ?

Any hints to do it ?
Any Example ?
Regards,
Cybertof.
Nov 15 '05 #1
4 5156
Cybertof,

It sounds like you want a stongly-typed dictionary. You can extend
DictionaryBase. However, you would have to implement the functionality that
would sort the list based on a field in the value (that field being a public
field or a property). Managing this is going to have a performance impact
as well.

On top of that, you will have to change the enumerator so that it
returns the items in the dictionary in the order you want. Like the
Hashtable, it should return a structure with the key/value pair, and not
just the value.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldin o=at=exisconsul ting<dot>com

"Cybertof" <cy************ ****@gmx.net> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Hi !

I would like to make an array of structure (collection ?) that would
behave like an advanced sorted list : a sorted list with one key but
with multiple values (sorted lists are key/value items).

- indexed by value index or by key (2 indexers)
- sortable by key or a secondary key
- supporting foreach loops
Is there a class my 'ExtendedList' could inherit from that would make
the most part of the job ?

Any hints to do it ?
Any Example ?
Regards,
Cybertof.

Nov 15 '05 #2
Nicholas,

What do you mean with
'Managing this is going to have a perfomance impact' ?

Is there a more efficient way ?

What is the restriction you are speaking about when you say
"Like the Hashtable, it should return a structure with the key/value
pair, and not just the value."

Regards,
Cybertof.

In article <#K************ *@tk2msftngp13. phx.gbl>,
ni************* *@exisconsultin g.com says...
Cybertof,

It sounds like you want a stongly-typed dictionary. You can extend
DictionaryBase. However, you would have to implement the functionality that
would sort the list based on a field in the value (that field being a public
field or a property). Managing this is going to have a performance impact
as well.

On top of that, you will have to change the enumerator so that it
returns the items in the dictionary in the order you want. Like the
Hashtable, it should return a structure with the key/value pair, and not
just the value.

Hope this helps.

Nov 15 '05 #3
Cybertof,

The reason it will have a performance impact is that in addition to
storing the value, on each add, insert, and removal of an item, you are
going to have to calculate where in the list it belongs, and that takes
time.

If you do a foreach on a Hashtable, you will be returned an instance of
type DictionaryEntry , which has a field for the key, and a field for the
value in the Hashtable. Your object should reflect this as well, instead of
just returning a value.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldin o=at=exisconsul ting<dot>com
"Cybertof" <cy************ ****@gmx.net> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Nicholas,

What do you mean with
'Managing this is going to have a perfomance impact' ?

Is there a more efficient way ?

What is the restriction you are speaking about when you say
"Like the Hashtable, it should return a structure with the key/value
pair, and not just the value."

Regards,
Cybertof.

In article <#K************ *@tk2msftngp13. phx.gbl>,
ni************* *@exisconsultin g.com says...
Cybertof,

It sounds like you want a stongly-typed dictionary. You can extend
DictionaryBase. However, you would have to implement the functionality that would sort the list based on a field in the value (that field being a public field or a property). Managing this is going to have a performance impact as well.

On top of that, you will have to change the enumerator so that it
returns the items in the dictionary in the order you want. Like the
Hashtable, it should return a structure with the key/value pair, and not
just the value.

Hope this helps.

Nov 15 '05 #4
Maybe there is something i don't understand, but why should my object
return a (key,value) pair if i already know the key itself (because i
use it during the 'call' to the search through the key indexer) ?

Cybertof.
In article <ey************ **@TK2MSFTNGP11 .phx.gbl>,
ni************* *@exisconsultin g.com says...
If you do a foreach on a Hashtable, you will be returned an instance of
type DictionaryEntry , which has a field for the key, and a field for the
value in the Hashtable. Your object should reflect this as well, instead of
just returning a value.

Nov 15 '05 #5

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

Similar topics

0
1596
by: Daniele Varrazzo | last post by:
If you need a container to look into, there is the sets module that provides a couple of them. If you need a sorted list, there is the bisect module. But i don't think it fits your need for a quick lookup: it's a python module so probably it's slower. Furthermore you can __hash__ almost everything, but you can __cmp__ in a consistent way much less stuff. Take definitely a look at sets.
57
3631
by: Egor Bolonev | last post by:
why functions created with lambda forms cannot contain statements? how to get unnamed function with statements?
5
52121
by: MackS | last post by:
Dear all, I've got several large sets in my program. After performing several operations on these I wish to present one set to the user sorted according to a certain criterion. Is there any direct way to do so? Or must I list = for item in set1:
10
15145
by: Der Andere | last post by:
I need to implement a sorted (ordered) list. STL has no sorted list type as far as I know. Is there a (straight) way to implement a sorted list using STL? BTW: The type of items in the list will be a class. Is it necessary to implement the > or < operators or to write a compare-function that returns the larger or smaller of two classes? Ideally, the list begins with the smallest element. Cheers, Matthias
3
22079
by: Andrew Clark | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** it's been a while since i have poseted to this newsgroup, but for a long time i was not programming at all. but now that i am out of college and facing the prospect of getting a real job, i need to get back into the game. anyway, i don't know if some of you know the stanford CS library. i took the problem set a while back and have recently rediscovered it adn have been trying...
1
1653
by: J L | last post by:
I want to create a sorted list whose values are themselves sorted lists. I wrote the following simple test program but it does not behave as I would expect. What I wanted to do was have the doorConflictList be keyed on a door ID and contain a sorted list called conFlictList. I wrote this expecting the following doorConflictList should end up with 3 items. Item 1 would be a sorted list with 1 item
4
1866
by: shrishjain | last post by:
Hi All, I need a type where I can store my items in sorted order. And I want to keep adding items to it, and want it to remain sorted. Is there any type in .net which I can make use of. I see there is SortedList<key, value> for hash tables, but could find anything for a sorted list. Currently I am using List<string> and whenever I add an item, I need to
1
1594
by: Khayrat | last post by:
Hi folks, please help I have a xml file with a list of items. The list is sorted during xslt processing. Based on this sorted list I want a navigation facility to walk through the sorted list starting from a choosen item via <back> and <next>. Say this is the list: <a>
8
2598
by: Guy | last post by:
Is there a better way to search identical elements in a sorted array list than the following: iIndex = Array.BinarySearch( m_Array, 0, m_Array.Count, aSearchedObject ); aFoundObject= m_Array; m_ResultArray.Add ( aFoundObject);
0
9674
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10560
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10604
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10261
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5659
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4466
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.