Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
81 views

Does a crate exist providing a fixed-size hash map in Rust [closed]

I'm looking for a crate providing a type with functionality similar to HashMap and preferably with the amazing speed of hashbrown, but with a setting to prevent the map from growing beyond a certain ...
Kile Asmussen's user avatar
5 votes
2 answers
104 views

How to more nicely pull all values from hash that aren't a given key?

I know how to get all of the values of a hash given a set of keys: use strict; use warnings; use DDP; my %h = ( a => 1, b => 2 ); my @v = @h{a,b}; p @v; # ( 1, 2 ) However I'm not sure ...
Rawley Fowler's user avatar
1 vote
2 answers
133 views

How do I get all keys of a maximum value from a HashMap in Rust?

In Rust, how can I get all keys from a HashMap that have a maximum value? Say I have something like this: let words = vec!["Hello", "World", "Hello", "everybody"...
TheJanzap's user avatar
  • 173
3 votes
1 answer
190 views

Custom hasher is faster for insert and remove, but when done together is slower, when comparing to std::collections::HashMap

I wish to benchmark various hashmaps for the <K,V> pair <u8, BoxedFnMut> where BoxedFnMut. type BoxedFnMut = Box<dyn FnMut() + Send + 'static>; To do this, I am using divan(0.1.21) ...
Naitik Mundra's user avatar
3 votes
2 answers
157 views

Mixed-type hash table design

I think this is a design problem. I’m trying to implement a hash table library in C89 in which the user will be able to insert mixed-type literal keys and values, e.g., HT_SET_LITERAL(&ht, "...
os_user's user avatar
  • 31
0 votes
2 answers
115 views

If I specify the capacity of a dictionary through the constructor, should I use a prime? [closed]

I am initializing a fairly large dictionary in C#. I have benchmarked the speed of building the dictionary with the capacity and without. It is (as expected) significantly faster (and uses ...
FluidMechanics Potential Flows's user avatar
-7 votes
1 answer
91 views

Stuck at a test case cant understand the prolem [closed]

I am trying to improve my coding skills and I got stuck at a question and can't understand the test case. I passed the first 5 test cases but got stuck at the last one: Top K Frequent Elements Given ...
khuzi yunus's user avatar
0 votes
0 answers
49 views

What's the differences between using is_transparent = void vs std::false_type vs std::true_type? [duplicate]

Say I want to enable heterogeneous lookup for associative containers by the Compare below, what difference does the type of tag is_transparent make? struct Compare { // What difference do the ...
PkDrew's user avatar
  • 2,659
0 votes
1 answer
68 views

Couldn't understand on how lookup in a hashmap is O(N) while iterating over the same [duplicate]

I was doing leet code and came across https://leetcode.com/problems/two-sum/description/, which I've tried solving with a seen counter using hashmap. Below is the code: class Solution: def twoSum(...
jai's user avatar
  • 1
0 votes
0 answers
86 views

Double encoded HashMap in rust

I have some data that is a 1:1 map of ids to strings, and I'd love a data structure that lets me query one to get the other. For example: let mut map:DoubleMap<i32,String> = DoubleMap::new(); ...
Hovestar's user avatar
  • 1,627
2 votes
4 answers
358 views

How to define Rust HashMap where the keys are refences to the values?

I am porting some of my more complex C++ code over to Rust as a way to learn the language. One thing I have is a map of values keyed by a std::string held inside the value type, to avoid copying the ...
user avatar
0 votes
0 answers
87 views

Having a class that supports operator overloads for both itself, a hashmap overload

I have a custom Node class that needs to be used with a custom hashmap and compare value eg. std::unordered_map<std::shared_ptr<Node>, double, Node::Hash, Node::Compare> neighbors; Right ...
raaj's user avatar
  • 3,459
-3 votes
1 answer
120 views

PriorityQueue Comparator weird behavior when sort order is fetched from hashmap

While working in LeetCode 675, I came across a weird behavior with PriorityQueue Comparator that I can't explain. For brevity, I'll state the gist of the problem statement; interested parties can read ...
Abhijit Sarkar's user avatar
2 votes
1 answer
117 views

Java how does searching for a key in a HashMap bucket work?

EDIT: As one of the people commenting mentioned, this question only concerns this specific implementation: https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/HashMap.java#...
Sebastian's user avatar
3 votes
2 answers
118 views

Insert to a HashMap if the key doesn't already exist, without cloning the key if it already exists?

I have a HashMap whose key type holds a heap allocation. I don't know if the HashMap already contains a particular key, and I would like to insert a new entry if the key doesn't already exist. How ...
Bernard's user avatar
  • 5,790

15 30 50 per page
1
2 3 4 5
1022