CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2009
    Posts
    1

    Hash Table - Multiple Keys for the same Data

    Hello,

    I have been searching on the Internet for a Hash Table (C++) which admits that a Data has multiple Keys, but I have only seen hash tables that admits only one key for a data. (SGI, BOOST, etc)

    My problem is the generation of triangular mesh for the solution of partial differential equations. My Data is a Triangle and each triangle has three Keys. Each Key is a vertex of the triangle. So, I need that the follow queries be answered easily and fast:

    1) Given a Vertex, return a list of Triangles which share this Vertex.
    2) Given three Vertexes, return the Triangle which is formed by those vertexes.

    I have implemented a template class HashTable which makes these queries possible, but I'm wondering if the name of such data structure is Hash Table because I have not seen nothing similar.

  2. #2

    Re: Hash Table - Multiple Keys for the same Data

    It's certainly a map of some time, and if it's implemented using hashing then it's a hash table. I'm not sure whether the advantage of your structure over either having a map/hash table of vertex to list of triangles, and then either intersecting the results of doing three look-ups or scanning the result of one look-up to find matching triangles (if there only a few triangles for each vertex), or having one table for the vertex -> list of triangles mapping and another table of tuple(vertex,vertex,vertex) -> triangle mapping. Implementing custom maps can be efficient, but can also be complicated for the performance (space or speed) gained.

  3. #3
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Hash Table - Multiple Keys for the same Data

    A big question is the relative rate of insertion/deletion to lookup. In general performance using a given datstructure is optimized for one or the other (or balanced - providing good, but sub-optimal performance for both).

    The second biggest question, is the SIZE of the collection. If the collection is small (relative to the capabilities of the system), then duplication of information can significantly speed up performance. On the other hand, HUGE collections (or extremely limited systems) may mandate slower performance to conserve memory.

    Until these are resolved, there is little more that can be said (except the elimination of alternatives which are poor under ALL conditions).
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured