Skip to content

Instantly share code, notes, and snippets.

@hamannjames
hamannjames / hashTableLinkedList.js
Last active August 1, 2022 13:34
Javascript hash table with linked lists in buckets
// code pen url: https://codepen.io/jaspercreel/pen/RgXjEp
// Declaring a node and list class outside of the hash class avoids binding issues with this
// The node class should only be created with a key value pair
class Node {
constructor(key, value) {
this[key] = value;
this.next = null;
}
@klugjo
klugjo / LinkedList.js
Last active February 16, 2020 18:21
LinkedList ES6 Implementation
class LinkedList {
constructor() {
this.head = null;
this.tail = null;
this.count = 0;
}
get length() {
return this.count;
}
@alexhawkins
alexhawkins / hashTable.js
Last active July 25, 2024 03:38
A Simple Hash Table in JavaScript
/*HASH TABLE - a dictionary/hash map data structure for storing key/value pairs. Finding
an entry in a hash table takes O(1) constant time(same for 10 as 1 billion items). Whereas
finding an item via binary search takes time proportional to the logarithm of
the item in the list O(logn). Finding an item in a regular old list takes time proportional to
the length of the list O(n). Very slow. Hash Tables = very fast */
var makeHashTable = function(max) {
var storage = [],
hashTableMethods = {
@ggilder
ggilder / linked_stack.js
Created August 1, 2012 07:29
Linked List Javascript implementation (node.js)
var assert = require('assert');
var LinkedStack = (function(){
function Item(data){
this.data = data;
this.next = null;
}
Item.prototype = {
tail: function(){