All Projects → purpleprotocol → Hashcow

purpleprotocol / Hashcow

Licence: mit
A Rust HashMap implementation with copy-on-write keys and values

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Hashcow

Datastructures Algorithms
This repo contains links of questions and their solution for interview prepration from geeksforgeeks, leetcode, etc.
Stars: ✭ 262 (+803.45%)
Mutual labels:  data-structure
Algorithms
Minimal examples of data structures and algorithms in Python
Stars: ✭ 20,123 (+69289.66%)
Mutual labels:  data-structure
Book on python algorithms and data structure
🪐 Book on Python, Algorithms, and Data Structures. 🪐
Stars: ✭ 604 (+1982.76%)
Mutual labels:  data-structure
Mytinystl
Achieve a tiny STL in C++11
Stars: ✭ 4,813 (+16496.55%)
Mutual labels:  data-structure
Data Structure
基于java语言的数据结构及算法实现,LeetCode算法示例
Stars: ✭ 348 (+1100%)
Mutual labels:  data-structure
Usaco Guide
A free collection of curated, high-quality resources to take you from Bronze to Platinum and beyond.
Stars: ✭ 439 (+1413.79%)
Mutual labels:  data-structure
contest.js
Ready for contest use! Data structures and algorithms in pure JavaScript with zero dependency.
Stars: ✭ 14 (-51.72%)
Mutual labels:  data-structure
Awesome Unam
A curated list of awesome engineering ecosystem, including UNAM Projects
Stars: ✭ 10 (-65.52%)
Mutual labels:  data-structure
Ocaml Containers
A lightweight, modular standard library extension, string library, and interfaces to various libraries (unix, threads, etc.) BSD license.
Stars: ✭ 367 (+1165.52%)
Mutual labels:  data-structure
Swiftgraph
A Graph Data Structure in Pure Swift
Stars: ✭ 588 (+1927.59%)
Mutual labels:  data-structure
Swift Algorithm Club Cn
swift-algorithm-club的翻译。使用Swift学习算法和数据结构。
Stars: ✭ 304 (+948.28%)
Mutual labels:  data-structure
Tinyqueue
The smallest and simplest priority queue in JavaScript.
Stars: ✭ 322 (+1010.34%)
Mutual labels:  data-structure
Interactive Coding Challenges
120+ interactive Python coding interview challenges (algorithms and data structures). Includes Anki flashcards.
Stars: ✭ 24,317 (+83751.72%)
Mutual labels:  data-structure
Ipfs Log
Append-only log CRDT on IPFS
Stars: ✭ 269 (+827.59%)
Mutual labels:  data-structure
Rpds
Rust Persistent Data Structures
Stars: ✭ 613 (+2013.79%)
Mutual labels:  data-structure
LeetCode-Py
⛽️「算法通关手册」,超详细的「算法与数据结构」基础讲解教程,「LeetCode」650+ 道题目 Python 版的详细解析。通过「算法理论学习」和「编程实战练习」相结合的方式,从零基础到彻底掌握算法知识。
Stars: ✭ 881 (+2937.93%)
Mutual labels:  data-structure
Samples
Sample projects using Material, Graph, and Algorithm.
Stars: ✭ 386 (+1231.03%)
Mutual labels:  data-structure
Algorithm Visualizer
🎆Interactive Online Platform that Visualizes Algorithms from Code
Stars: ✭ 35,995 (+124020.69%)
Mutual labels:  data-structure
Algorithm
Algorithm is a library of tools that is used to create intelligent applications.
Stars: ✭ 787 (+2613.79%)
Mutual labels:  data-structure
Lintcode
📘 C++11 Solutions of All 289 LintCode Problems (No More Updates)
Stars: ✭ 570 (+1865.52%)
Mutual labels:  data-structure

HashCow

Build Status Discord Badge Latest Version Documentation

HashCow is a Rust HashMap implementation with copy-on-write keys and values.


Originally built for optimizing the Purple Protocol, this library provides a way to link HashMaps in memory that have duplicate entries. Instead of the duplicate data, it is instead borrowed and it is only cloned when mutation is needed.

Using HashCow

use hashcow::{Form, CowHashMap};

let mut hm: CowHashMap<str, [u8]> = CowHashMap::new();

// We insert an owned value in the map
hm.insert_owned("key".to_owned(), vec![1, 2, 3]);
assert_eq!(hm.entry_form(&"key").unwrap(), Form::Owned);

// We now create a clone with borrowed fields
let mut hm_clone = hm.borrow_fields();
assert_eq!(hm_clone.entry_form(&"key").unwrap(), Form::Borrowed);

// On mutation, the borrowed entry is cloned
let entry = hm_clone.get_mut(&"key").unwrap();

// We now mutate the cloned value
*entry = vec![4, 5, 6];
assert_eq!(hm_clone.entry_form(&"key").unwrap(), Form::Owned);

// The two maps now have different entries for the same key
assert_eq!(hm.get(&"key").unwrap(), &[1, 2, 3]);
assert_eq!(hm_clone.get(&"key").unwrap(), &[4, 5, 6]);

Contributing

We welcome anyone wishing to contribute to HashCow! Check out the issues section of the repository before starting out.

License

HashCow is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].