A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2005-March/051981.html below:

[Python-Dev] LinkedHashSet/LinkedHashMap equivalents

[Python-Dev] LinkedHashSet/LinkedHashMap equivalentsMichael Hudson mwh at python.net
Thu Mar 10 09:42:55 CET 2005
"Delaney, Timothy C (Timothy)" <tdelaney at avaya.com> writes:

> Set: Items are iterated over in the order that they are added. Adding an
> item that compares equal to one that is already in the set does not
> replace the item already in the set, and does not change the iteration
> order. Removing an item, then re-adding it moves the item to the end of
> the iteration order.

Well, this could be satisfied by an append_new operation on lists,
right (thinking of Common Lisps #'cl:pushnew)?  Complexity not that
great, of course, but I've written code like:

if a not in l:
    l.append(a)

and not suffered that badly for it before now...

> Dict: Keys are iterated over in the order that they are added. Setting a
> value using a key that compares equal to one already in the dict
> replaces the value, but not the key, and does not change the iteration
> order. Removing a key (and value) then re-adding it moves the key to the
> end of the iteration order.

And these are what CL types call association lists, in effect.

Cheers,
mwh

-- 
  #ifndef P_tmpdir
  printf( "Go buy a better computer" );
  exit( ETHESKYISFALLINGANDIWANTMYMAMA );
                         -- Dimitri Maziuk on writing secure code, asr
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4