Sha256: 54d67a7e386b7527d6f3c6ffa92210a34744f31574a2e7aef371dc0d29141206

Contents?: true

Size: 697 Bytes

Versions: 13

Compression:

Stored size: 697 Bytes

Contents

var ensureTwoPower = function(n) {
	if (n && !(n & (n - 1))) return n;
	var p = 1;
	while (p < n) p <<= 1;
	return p;
};

var Cyclist = function(size) {
	if (!(this instanceof Cyclist)) return new Cyclist(size);
	size = ensureTwoPower(size);
	this.mask = size-1;
	this.size = size;
	this.values = new Array(size);
};

Cyclist.prototype.put = function(index, val) {
	var pos = index & this.mask;
	this.values[pos] = val;
	return pos;
};

Cyclist.prototype.get = function(index) {
	return this.values[index & this.mask];
};

Cyclist.prototype.del = function(index) {
	var pos = index & this.mask;
	var val = this.values[pos];
	this.values[pos] = undefined;
	return val;
};

module.exports = Cyclist;

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
jester-data-8.0.0 node_modules/cyclist/index.js
ezii-os-5.2.1 node_modules/cyclist/index.js
ezii-os-2.0.1 node_modules/cyclist/index.js
ezii-os-1.1.0 node_modules/cyclist/index.js
ezii-os-1.0.0 node_modules/cyclist/index.js
ezii-os-0.0.0.1.0 node_modules/cyclist/index.js
ezii-os-0.0.0.0.1 node_modules/cyclist/index.js
optimacms-0.4.3 spec/dummy/node_modules/cyclist/index.js
optimacms-0.4.2 spec/dummy/node_modules/cyclist/index.js
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/cyclist/index.js
locomotivecms-3.4.0 app/javascript/node_modules/cyclist/index.js
cortex-0.1.3 spec/dummy/node_modules/cyclist/index.js
dragonfly_puppeteer-0.1.0 node_modules/cyclist/index.js