Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azusfin/structures
Implementations of Data Structures
https://github.com/azusfin/structures
bits bytes data-structures structures tree
Last synced: about 1 month ago
JSON representation
Implementations of Data Structures
- Host: GitHub
- URL: https://github.com/azusfin/structures
- Owner: Azusfin
- License: mit
- Created: 2022-03-20T03:29:20.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-21T04:54:01.000Z (almost 3 years ago)
- Last Synced: 2024-11-08T06:42:51.381Z (3 months ago)
- Topics: bits, bytes, data-structures, structures, tree
- Language: TypeScript
- Homepage: https://azusfin.github.io/structures
- Size: 178 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @azusfin/structures
> Implementations of Data Structures# API Documentation
https://azusfin.github.io/structures# Table Of Contents
- [BitSet](#bitset)
- [Uint4Array](#uint4array)
- [Int4Array](#int4array)## BitSet
A static-length array to work with bytes in bit-level- [Init](#init-bitset)
- [Set](#set-bit)
- [Get](#get-bit)
- [Flip](#flip-bit)
- [Clear](#clear-bit)### Init BitSet
```js
import { BitSet } from "@azusfin/structures"const bitsAmount = 64
const bitSet = new BitSet(bitsAmount)
```### Set Bit
```js
const index = 31
bitSet.set(index)
```### Get Bit
```js
bitSet.get(31) // true
bitSet.get(4) // false
```### Flip BIt
```js
bitSet.flip(31)
bitSet.flip(4)bitSet.get(31) // false
bitSet.get(4) // true
```### Clear Bit
```js
bitSet.clear(31)
bitSet.clear(4)bitSet.get(31) // false
bitSet.get(4) // false
```## Uint4Array
An array where each element occupies 4 bit unsigned integer from 0 to 15- [Init](#init-uint4array)
- [Set](#set-uint4array)
- [Get](#get-uint4array)### Init Uint4Array
```js
import { Uint4Array } from "@azusfin/structures"const length = 8
const array = new Uint4Array(length)
```### Set Uint4Array
```js
const offset = 3
array.set(offset, 12)
array.set(1, 6)
array.set(5, 3)
```### Get Uint4Array
```js
array.get(offset) // 12
array.get(1) // 6
array.get(5) // 3
```## Int4Array
A subtype of Uint4Array with support of 4 bit signed integer from -8 to 7- [Init](#init-int4array)
- [Set](#set-int4array)
- [Get](#get-int4array)### Init Int4Array
```js
import { Int4Array } from "@azusfin/structures"const length = 8
const array = new Int4Array(length)
```### Set Int4Array
```js
const offset = 3
array.set(offset, -4)
array.set(1, -8)
array.set(5, 3)
```### Get Int4Array
```js
array.get(offset) // -4
array.get(1) // -8
array.get(5) // 3
```