Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'array.': 0.09; 'deletion': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; '(key,': 0.16; 'encode': 0.16; 'subject:independent': 0.16; 'wrote:': 0.18; 'memory': 0.21; 'programming': 0.21; 'mechanism': 0.21; 'result.': 0.21; 'header:In-Reply-To:1': 0.22; 'dictionary': 0.23; 'pair': 0.23; 'tree.': 0.23; 'defined': 0.24; 'index': 0.24; "python's": 0.24; 'structure': 0.26; 'pm,': 0.29; 'hash': 0.30; 'value)': 0.30; 'subject:?': 0.31; 'objects': 0.32; 'implement': 0.32; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'there': 0.33; 'object': 0.33; 'to:addr:python-list': 0.34; 'normally': 0.34; 'describing': 0.34; 'integer': 0.34; 'keys': 0.34; 'maintains': 0.34; 'operations': 0.35; 'properties': 0.36; 'received:au': 0.36; 'uses': 0.36; 'but': 0.37; 'run': 0.37; 'using': 0.38; 'received:org': 0.38; 'some': 0.38; 'programming.': 0.39; 'ways': 0.39; 'to:addr:python.org': 0.40; 'might': 0.40; 'management': 0.60; 'type': 0.61; 'grow': 0.62; 'auto': 0.63; 'collection': 0.69; 'inquiring': 0.84; 'received:110': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Lie Ryan Subject: Re: order independent hash? Date: Mon, 05 Dec 2011 00:29:15 +1100 References: <30715729.411.1322753732534.JavaMail.geo-discussion-forums@pret21> <4ED7A2CE.6070306@davea.name> <6366868.86.1322800180523.JavaMail.geo-discussion-forums@pret21> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 110-175-240-90.static.tpgi.com.au User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 In-Reply-To: <6366868.86.1322800180523.JavaMail.geo-discussion-forums@pret21> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1323005372 news.xs4all.nl 6856 [2001:888:2000:d::a6]:58423 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16605 On 12/02/2011 03:29 PM, 88888 Dihedral wrote: > > I clear my point a hash is a collection of (key, value) pairs that have > well defined methods and behavior to be used in programming. > > The basic operations of a hash normally includes the following: > > 1. insertion of a (key, value) pair into the hash > 2. deletion of a (key, value) from the hash > 3. inquiring a hash by a key to retrieve the value if the (key, value) > pair available in the hash. If no key matched, the hash will return > a not found result. > > The hash can grow with (k,v) pairs accumulated in the run time. > An auto memory management mechanism is required for a hash of a non-fixed size of (k,v) pairs. > > Some implementations of a hash might pose some restrictions of k and v > for some reasons. But in object programming k and v can be objects > to be manipulated by the programmer. Strictly speaking, what you're describing is just a dictionary/mapping abstract data type (ADT), not a hashtable. Hashtable is a particular way to implement the dictionary/mapping ADT. Python's dictionary is implemented as hashtable, but there are other ways to implement a dictionary/mapping, such as using a sorted tree. For a data structure to be considered a Hashtable, in addition to having the properties of a dictionary that you described, the data structure must also uses a "hashing function" to encode the dictionary's keys into integer that will be used to calculate the index for the corresponding value in its internal array. A hashtable also must provide mechanism to deal with hash collisions to maintains its invariants as a dictionary.