• Stars
    star
    212
  • Rank 186,122 (Top 4 %)
  • Language
    Elixir
  • Created over 11 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Datastructures for Elixir.

Datastructures for Elixir

This is a collection of protocols, implementations and wrappers to work with datastructures.

The stdlib of Elixir right now is very poor and every now so you end up using the Erlang libraries, which have different APIs from the rest of idiomatic Elixir, and on top of that they lose all the protocol goodies.

Protocols

Sequence

  • first/1 - returns the first element in the sequence or nil
  • next/1 - returns a new sequence with the first element removed or nil

Counted

  • count - returns the length of the structure

Emptyable

  • empty?/1 - checks if the structure is empty
  • clear/1 - returns an empty structure

Reducible

  • reduce/3 - reduces the structures

Sequenceable

  • to_sequence/1 - converts the structure to a sequence

Listable

  • to_list/1 - converts the structure to a list

Peekable

  • peek/1 - peeks and returns nil if the structure empty
  • peek/2 - peeks and returns the default value if the structure empty
  • peek!/1 - peeks and raises if the structure is empty

Reversible

  • reverse/1 - reverses the structure

Contains

  • contains?/2 - checks if the structure contains the passed value

Queue

  • enq/2 - enqueues a value in the structure
  • deq/1 - dequeues a value from the structure, returning nil if it's empty
  • deq/2 - dequeues a value from the structure, returning the default if it's empty
  • deq!/1 - dequeues a value from the structure, raising if it's empty

Stack

  • push/2 - pushes a value in the structure
  • pop/1 - pops a value from the structure, returning nil if it's empty
  • pop/2 - pops a value from the structure, returning the default if it's empty
  • pop!/1 - pops a value from the structure, raising if it's empty

Set

  • add/2 - adds a value to the structure
  • delete/2 - deletes a value from the structure
  • union/2 - returns the union of the two structures
  • intersection/2 - returns the intersection of the two structures
  • subset?/2 - checks if the two structures are subsets
  • disjoint?/2 - checks if the two structures are disjoint

Dictionary

  • get/2 - gets a value from the structure by its key, returning nil if there isn't one
  • get/3 - gets a value from the structure by its key, returning the default if there isn't one
  • get!/2 - gets a value from the structure by its key, raising if there isn't one
  • put/3 - puts a value in the structure with its key
  • delete/2 - delete a value from the structure by its key
  • keys/1 - returns a list of the keys in the structure
  • values/1 - returns a list of the values in the structure

Helpers

Dict

  • get/2 - gets a value from the structure by its key, returning nil if there isn't one
  • get/3 - gets a value from the structure by its key, returning the default if there isn't one
  • get!/2 - gets a value from the structure by its key, raising if there isn't one
  • put/3 - puts a value in the structure with its key
  • delete/2 - delete a value from the structure by its key
  • keys/1 - returns a list of the keys in the structure
  • values/1 - returns a list of the values in the structure
  • put_new/3 - puts a value in the structure unless there's already one with that key
  • update/3 - updates the structure with an updater function, raises if there's no value with that key
  • update/4 - updates the structure with an updater function, the initial value is passed if there's no value with that key

Seq

  • with_index/1 - returns a sequence wrapping the sequence and returning indexes
  • all?/1 - checks all elements in the sequence are truthy
  • all?/2 - checks all elements are truthy with the given predicate
  • any?/1 - checks if any element in the sequence is truthy
  • any?/2 - checks if any element in the sequence is truthy with the given predicate
  • at/2 - gets the element at the given index, returns nil if the sequence is shorter
  • at/3 - gets the element at the given index, returns the default value if the sequence is shorter
  • drop/2 - drops the given number of elements from the sequence
  • drop_while/2 - drops elements from the sequence as long as the predicate returns a truthy value
  • take/2 - take the given number of elements from the sequence
  • take_while/2 - take elements from the sequence as long as the predicate returns a truthy value
  • each/2 - iterate over the sequence
  • select/2 - filters the elements from the sequence returning the ones the predicate returns a truthy value for
  • reject/2 - filters the elements from the sequence returning the ones the predicate returns a falsy value for
  • map/2 - returns the sequence mapped with the given function
  • reduce/3 - reduce the sequence
  • sort/1 - sort the sequence
  • sort/2 - sort the sequence with the given predicate
  • count/1 - count the elements in the sequence
  • count/2 - count the elements in the sequence that match the predicate
  • zip/2 - zip two sequences together
  • max/1 - return the max value in the sequence
  • max/2 - return the max value in the sequence using a mapper
  • min/1 - return the min value in the sequence
  • min/2 - return the min value in the sequence using a mapper
  • uniq/1 - returns the elements without repetitions
  • uniq/2 - returns the elements without repetitions using a mapper
  • reverse/1 - reverse the sequence
  • to_list/1 - convert the sequence to a list

You're awful, those names are long

I know right? Just use alias.

alias Data.Set, as: S
alias Data.Set.BalancedTree, as: SBT

SBT.new |> S.add(23) |> S.add(42) # => #Set<[23,42]>

More Repositories

1

amnesia

Mnesia wrapper for Elixir.
Elixir
682
star
2

elixir-socket

Socket wrapping for Elixir.
Elixir
679
star
3

ruby-tesseract-ocr

A Ruby wrapper library to the tesseract-ocr API.
Ruby
627
star
4

ruby-thread

Various extensions to the base thread library.
Ruby
525
star
5

rust-ffmpeg

Safe FFmpeg wrapper.
Rust
454
star
6

rust-tun

TUN device creation and handling.
Rust
215
star
7

rust-ffmpeg-sys

moved to meh/rust-ffmpeg
Rust
146
star
8

cancer

It's terminal.
Rust
129
star
9

urna

REST in peace.
Elixir
95
star
10

smart-referer

MOVED to GitLab: https://gitlab.com/smart-referer/smart-referer/
JavaScript
94
star
11

reagent

You need more reagents to conjure this server.
Elixir
92
star
12

dux

DUX MEA LUX
Rust
89
star
13

exquisite

LINQ-like match_spec generation for Elixir.
Elixir
78
star
14

rust-packet

Network packet handling for Rust.
Rust
76
star
15

cauldron

I wonder what kind of Elixir is boiling in there.
Elixir
74
star
16

jazz

Yet another library to handle JSON in Elixir.
Elixir
61
star
17

rorschach

And I'll look down and whisper "GNO."
Rust
59
star
18

screenruster

X11 screen saver and locker.
Rust
53
star
19

miserve

Servo based minimal browser.
PostScript
48
star
20

blender

Blend in the crowd by faking to be the most common Firefox browser version, operating system and other stuff.
Ruby
42
star
21

rust-terminfo

Terminal information for Rust.
Rust
40
star
22

rust-uinput

Linux uinput wrapper.
Rust
39
star
23

lissio

E vai col lissio!
Ruby
39
star
24

cesso

CSV handling library for Elixir.
Elixir
26
star
25

rust-xcb-util

Rust bindings and wrappers for XCB utility functions.
Rust
26
star
26

ruby-mbox

A Ruby mbox parser.
Ruby
23
star
27

steamy

Steam controller handling.
Rust
21
star
28

ruby-threadpool

A simple no-wasted-resources thread pool implementation.
Ruby
21
star
29

ruby-x11

X11 bindings for Ruby
Ruby
20
star
30

wrong

The most wrong build system and package manager for C and C++.
Makefile
19
star
31

elixir-benchmark

Elixir benchmark utilities.
Elixir
18
star
32

mad

Managers & Developers
18
star
33

rust-mailbox

MBOX reader.
Rust
17
star
34

rust-hid

HID access library.
Rust
15
star
35

moc

Mirror of the moc project, with some of my own changes
C
15
star
36

rust-shmem

Shared memory for Rust.
Rust
14
star
37

ruby-clj

Like json, but with clojure sexps.
Ruby
14
star
38

NetCommander

NetCommander - An easy to use arp spoofing tool.
Python
14
star
39

miniLOL

Not just a CMS.
JavaScript
12
star
40

derp

Elixir error logger.
Elixir
12
star
41

continuum

Spaaaaceeeeeeeeeeeee.
Elixir
12
star
42

nucular

A reactor in D.
D
12
star
43

ruby-torchat

Torchat implementation in Ruby, event-driven EventMachine based library.
Ruby
12
star
44

rust-sixel

Sixel encoder/decoder for Rust.
Rust
11
star
45

ruby-ffi-inline

Inline C/C++ in Ruby easily and cleanly.
Ruby
11
star
46

rust-lzma

LZMA handling library.
Rust
10
star
47

fag

Forums Are Gay.
Ruby
10
star
48

clj.js

parse/dump Clojure like you'd do with JSON
JavaScript
10
star
49

vimmeh

Vim Script
9
star
50

rust-bdf

BDF format handling.
Rust
9
star
51

bitlbee-omegle

Omegle plugin for BitlBee.
C
9
star
52

neovimmeh

Fennel
8
star
53

elixir-operators

Ever wanted operators which are as slow as can be? Now you can!
Elixir
8
star
54

arpoon

Man the harpoons, kill the spoofer!
Ruby
8
star
55

lulzKey

lulzKey. Let's close those effin Windows so penguins won't enter.
C++
8
star
56

exts

Elixir Terms Storage, ets wrapper.
Elixir
8
star
57

failirc

Fail IRC library in Ruby.
Ruby
7
star
58

lulzhttpd

A C++ web server.
C++
7
star
59

screenruster-saver

Helper library to create screen savers.
Rust
7
star
60

rust-uinput-sys

Linux uinput definitions.
Rust
7
star
61

elixir-managed_process

Garbage collected processes.
Elixir
7
star
62

npapi-mumble-link

Mumble Link wrapped as an NPAPI plugin.
C
7
star
63

expo

XPosed for Kotlin.
Kotlin
7
star
64

opentyrian

opentyrian mirror with some of my own changes
C
7
star
65

rust-picto

Image handling library for Rust.
Rust
6
star
66

shumei

Shumei brings an actor system and other concurrency plumbing primitives to the web.
TypeScript
6
star
67

ruby-fuse

Bindings and wrapper for FUSE with FFI.
Ruby
6
star
68

elixir-finalizer

Define finalizers using the cool NIF hack.
Elixir
6
star
69

random

Random codes.
Assembly
6
star
70

httprot

Prot prot prot.
Elixir
6
star
71

screenruster-saver-laughing_man

I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Rust
6
star
72

ruby-call-me

Various calling things, overload, pattern matching, memoization and such.
Ruby
6
star
73

rust-openal

OpenAL wrapper
Rust
6
star
74

orgasm

ORGanized ASseMbly: a Ruby (dis)?assembler library (NOT a (dis)?assembler FOR Ruby, a (dis)?assembler IN Ruby)
Ruby
6
star
75

llvm-lol

LOLCODE LLVM implementation.
C++
5
star
76

decimex

erlang-decimal wrapper for Elixir
Elixir
5
star
77

ruby-glyr

Ruby wrapper for glyr.
Ruby
5
star
78

nohomo

Homoglyphs begone!
Vim Script
5
star
79

clj-sockets

POSIX sockets for Clojure.
Clojure
5
star
80

rust-hwaddr

MAC address handling.
Rust
5
star
81

colorb

Colorify your strings
Ruby
5
star
82

rust-xkb

Rusty wrapper to libxkbcommon.
Rust
5
star
83

boolean-expression

A simple library to evaluate boolean expressions.
Ruby
5
star
84

bitlbee-torchat

Bitlbee plugin for using torchat.
C
5
star
85

amirite

Include and forget testing framework for C++11
C++
5
star
86

dexts

Disk Elixir Terms Storage, dest wrapper.
Elixir
5
star
87

nokku

Knock knock knock, hitori bocchi.
Rust
4
star
88

rust-xkbcommon-sys

Bindings to libxkbcommon.
Rust
4
star
89

screenruster-saver-hacks

ScreenRuster support for XScreenSaver hacks.
Rust
4
star
90

libcss

A library to parse and work with CSS
C
4
star
91

ela

Embedded Linear Algebra
C++
4
star
92

faildns

Fail DNS library in Ruby
Ruby
4
star
93

rust-curses-sys

Rust
3
star
94

ruby-clit

Simple library to make nice themeable CLI output.
Ruby
3
star
95

rft

Shitty Rust FFT implementation.
Rust
3
star
96

fagadget

New cross-toolkit and cross-platform desktop-gadget prototype.
C++
3
star
97

zwm

Shell
3
star
98

cryptsetup

Mirror of cryptsetup with some of my own changes
C
3
star
99

LOLastfm

LOL it's a scrobbler.
Ruby
3
star
100

parsepples

A parslet-like parser for C++
C++
3
star