Skip to content

Latest commit

 

History

History
64 lines (51 loc) · 1.98 KB

README.md

File metadata and controls

64 lines (51 loc) · 1.98 KB

Data Structures in Cairo

Just me playing with Cairo while learning about the language and implementing basic data structures.

Motivation

Mainly to learn more about the language, but also to contribute so that there are more examples of the Cairo syntax (who knows, maybe someone uses this and finds it useful).

Notes: I'm aiming to try to encapsulate functionality that complicates the user, for example always taking into account the length of the data structure. The trade-off is that we're constantly updating that variable in a dict and it's maybe a bit more expensive than a conventional implementation in Cairo, but I wanted to give you that approach.

What have we done so far?

Methods

- new_list()
- add(val: felt)
- get(idx: felt)
- remove(idx: felt)
- replace(idx: felt, val: felt)
- contains(val: felt)
- size()

- Set

Methods

- new_set()
- add(val: felt)
- get(idx: felt)
- remove(idx: felt)
- replace(idx: felt, val: felt)
- contains(val: felt)
- size()

Can see examples of use on the set_test.cairo (Using Protostar)

Methods

- new_queue()
- add(val: felt)
- peek()
- poll()
- size()

Can see examples of use on the queue_test.cairo (Using Protostar)

Methods

- new_heap()
- add(val: felt)
- peek()
- poll()
- contains(val: felt)
- size()

Can see examples of use on the min_heap_test.cairo (Using Protostar)