Posts: 4,647
Threads: 1,494
Joined: Sep 2016
i would like to have an object that operates like a set but iterates its contents in sorted order.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
May-20-2023, 10:59 PM
(This post was last modified: May-20-2023, 10:59 PM by Skaperen.)
i should have also said i want the fetch-one-next-item timing to be the same as or close that for plain set(). sorting the entire set and returning the first from that result is timing i want to avoid. i implemented this kind of thing in C many years ago and it has served me well for almost every container/dictionary usage over the years of coding in C. it worked like a set but allowed each item to be assigned a value. i could search for a given key from the front or the back. multiple items with the same key were allowed (and could be assigned different values). once found, the "next key" could be requested. the group of like keys were kept in the order inserted, and a "next by next" scan would step through them in that order. a "previous by previous" scan would get them in reverse order. it was implemented as an AVL binary tree and outperformed a hash up to a size around 1,200,000.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.