Answers for "is hashset has its own hash functions java"

0

hashset usage

- HashSet can have null, order is not guaranteed
- HashSet is commonly used if you want to access elements randomly or store a list of items which cannot contain duplicate values
Posted by: Guest on January-17-2022
0

hashset implementation

class MyHashSet {
private:
	vector<bool> table;
public:
	MyHashSet() : table(1e6 + 1, false) {}
	
	void add(int key) {
		table[key] = true;
	}
	
	void remove(int key) {
		table[key] = false;
	}
	
	bool contains(int key) {
		return table[key];
	}
};
Posted by: Guest on April-22-2022

Browse Popular Code Answers by Language