Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add low-level HashTable API #466

Merged
merged 9 commits into from
Oct 19, 2023
Merged

Add low-level HashTable API #466

merged 9 commits into from
Oct 19, 2023

Commits on Oct 18, 2023

  1. Add low-level HashTable API

    The primary use case for this type over [`HashMap`] or [`HashSet`] is to
    support types that do not implement the [`Hash`] and [`Eq`] traits, but
    instead require additional data not contained in the key itself to compute a
    hash and compare two elements for equality.
    
    `HashTable` has some similarities with `RawTable`, but has a completely
    safe API. It is intended as a replacement for the existing raw entry
    API, with the intend of deprecating the latter and eventually removing
    it.
    
    Examples of when this can be useful include:
    - An `IndexMap` implementation where indices into a `Vec` are stored as
      elements in a `HashTable<usize>`. Hashing and comparing the elements
      requires indexing the associated `Vec` to get the actual value referred to
      by the index.
    - Avoiding re-computing a hash when it is already known.
    - Mutating the key of an element in a way that doesn't affect its hash.
    
    To achieve this, `HashTable` methods that search for an element in the table
    require a hash value and equality function to be explicitly passed in as
    arguments. The method will then iterate over the elements with the given
    hash and call the equality function on each of them, until a match is found.
    Amanieu committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    f625528 View commit details
    Browse the repository at this point in the history
  2. Add HashTable::get_many_mut

    Amanieu committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    a2b8f18 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3b8426e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    06ba464 View commit details
    Browse the repository at this point in the history
  5. Update src/table.rs

    Co-authored-by: Josh Stone <cuviper@gmail.com>
    Amanieu and cuviper committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    cce9925 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    05bee57 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    878b5bf View commit details
    Browse the repository at this point in the history

Commits on Oct 19, 2023

  1. Minor cleanups

    Amanieu committed Oct 19, 2023
    Configuration menu
    Copy the full SHA
    cbbb823 View commit details
    Browse the repository at this point in the history
  2. Fix rustdoc warnings

    Amanieu committed Oct 19, 2023
    Configuration menu
    Copy the full SHA
    9556bf4 View commit details
    Browse the repository at this point in the history