|
Ah, I see what you're saying.
It's not really gnarly. Consider that when you need to edit a value you will have to resort the set anyway no matter how you slice it. And when you remove and readd there will never be a new allocation because you just had a free slot, so it's almost instant aside from the sort which had to happen anyway.
If your actual problem with it is it *looks* ugly, write an extension method I guess but it will just turn two lines of code into one.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: when you remove and readd there will never be a new allocation because you just had a free slot ... unless the collection auto-sizes on remove ?
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
They do not do that. They only ever increase in capacity - unless they have a Trim() method or allow you to set the Capacity property but the collections since 2.0 typically don't
Real programmers use butterflies
|
|
|
|
|
thanks ! I may have been thinking of SortedSet:
Starting with .NET Framework 4, the SortedSet<T> class provides a self-balancing tree that maintains data in sorted order after insertions, deletions, and searches. This class and the HashSet<T> class implement the ISet<T> interface. or, I may have made an unwarranted generalization from the auto-sizing facility of List<T>
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
List<t> doesn't shrink it's capacity. It grows and grows and grows and grows.
But I was wrong about SortedSet<T> after looking at SortedSet.cs in the reference implementation. Sorry.
I could have sworn they implemented it like Dictionary<TKey,TValue> .
In the dictionary they use a hashtable, but the hash just holds indexes into an internal array that grows when you add items.
In sorted set it's just a straight binary tree. unoptimized. So you were right about it shrinking on remove.
I should have looked it up before I said something. Mea culpa.
I don't trust any SortedXXXXX implementation under the ComponentModel now after seeing that.
Unfortunately the way to do it would be to reimplemented sorted set properly so instead of say
class Node {
public Node Left;
public Node Right;
}
It should be
struct Node {
public int LeftIndex;
public int RightIndex;
}
with
Node[] m_nodeList;
as an internal member, and that should grow.
That's how dictionary for example does things except it uses a hash instead of a tree.
ETA: The other option is to just use a sorted array. I'd consider that route.
Real programmers use butterflies
|
|
|
|
|
thanks for that very informative reply ! re: List<T> ... i am wrong ... what was i thinking ?honey the codewitch wrote: I don't trust any SortedXXXXX implementation under the ComponentModel now after seeing that. While there is sort-related "stuff" in that NameSpace, there are no sorted-xxx data structures; however, that is where INotify-xxx lives.
Now convinced my brain needs either a lobotomy or a systematic review of sorting, and PropChange-xxx ... I remain ... curious
Take a look at what Marc Gravell of SO uses for prop change: [^]
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
BillWoodruff wrote: i began to get angry as my cherished image of myself as an expert debugger
"Rebuggering" ???
|
|
|
|
|
"Woodruffing" has a nice ring to it.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
BillWoodruff wrote: the beast was doing what i told it to do
This is why I love programming.
cheers
Chris Maunder
|
|
|
|
|
i sometimes think part of the seductiveness of programming is the sense one's efforts occur in a kind of virtual reality sandbox... where the equivalent of real-world train-wrecks, earthquakes, tsunamis, etc., don't put you in a real morgue, or hospital.
however, i've never had code i wrote bring a satellite down, crash a server, or, cause a company to lose a zillion dollars.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
BillWoodruff wrote: i think we need a new word for this special kind of bruised-ego chagrin mixed with plummeting self-esteem
In the best tradition of turning adjectives into nouns and then into verbs, I suggest "to bad"
("bad" ==> "my bad" ==> "to bad")
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
I'm thinking something more weird, perhaps teutonic flavored, with obscure psychiatric top-notes
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Years ago I built a priority queue using SortedDictionary. It took less than a page. Looking at the documentation for SortedDictionary and comparing it to my college algorithms book, SortedDictionary uses the same underlying logic and data structures as a PriorityQueue.
Not sure why the framework guys thought this would be a good addition.
|
|
|
|
|
SortedDictionary, like other Sorted-xxx structures is only going to re-sort on 'Add operations.
In addition, it's Keys are immutable; if you used a DateTime as a Key, you'd up doing the remove, change, add dance.
I'm too old to dance
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
modified 14-May-21 7:22am.
|
|
|
|
|
|
I love Woz. He's a teddy bear.
Real programmers use butterflies
|
|
|
|
|
His book is really great too.
I think he really modernized the idea of building a "personal computer" or "desktop computer" because he is really the first one to hook up a keyboard (old typewriter) to a monitor (television screen) and enable the ability to type and see the character display on screen.
He talks about that in the book and his book is really a great read.
|
|
|
|
|
I'll have to buy it then. I already was considering it when you posted the link. =) Like I said, he's a teddy bear. I adore the man.
Real programmers use butterflies
|
|
|
|
|
It's been a long time since I read it, but I remember enjoying "The Soul of a New Machine", by Tracy Kidder. It covers the efforts of Data General to create a new minicomputer to compete with the DEC Vax.
Keep Calm and Carry On
|
|
|
|
|
Soul of a new machine
possibly my favourite non-fiction book
|
|
|
|
|
I've taken a look at that book before. I'll have to circle back and check it out again.
Thanks for the recommendation.
|
|
|
|
|
I wanted to post the same. I love that book. Crazy stuff that went down before the PC days, or at least before the ubiquitous PC days.
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
I also read it when it came out and definitely second your recommendation.
|
|
|
|
|
|
So I had a car-related need to install Windows 7 on a a 12-year Acer Aspire 5520 old laptop (that was running Linux). The laptop only has 4gb RAM (maxed out), so I figured doing a VM would needlessly inhibit Windows' performance, hence the clean Win7 install.
I have been in update hell for two days. It seems that when you get updates for a fresh Win7/SP1 install, you have to do the "important" updates in a specific order, because Windows Update isn't smart enough to apply updates that span 8 years in the correct order.
Also, I tried first updating the wireless, ethernet, and video drivers via Windows Update, and all that did was make the laptop completely unbootable. I'm thinking that might be caused by the need to apply 118 "important" updates.
Now that it's completely failed on me a few times, I'm gun-shy, and am only applying updates a few at a time.
All this so I can install a single application...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|