Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
an ADT i want to create
#1
i had a use case for this last night. this would be a mapping that can hold duplicate keys and retain the original insertion order within the same key. that is, if i do adt['foo']='bar' followed by adt['foo']='baz' then the 1st call adt.pop('foo') would get 'bar' and the next one would get 'baz'. a 3rd one would get the exception for a missing key. also, this ADT would keep one internal position state and have a method to access it at any time. insertion of any items would not change the position state. deletion of the item referenced by the position state would move the position forward if it is not the last or move it backward if it is the last. if this is only one item being deleted, the position reference "goes away" just like a newly created empty ADT. methods will exist to move the position forward or backward. methods will exist to jump to the beginning or end and if an optional key is given that jump is to the beginning or end of the items matching that key. if that key does not for these particular methods then there would be no exception and the position would move to the "virtual position" where such a keyed item would be so that forward or backward movement from there would go to a higher or lower keyed item.

i have already implemented this kind of ADT in C. a Python version may have some additions to it.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020