Skip to content

dubzn/data-structures-cairo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Data Structures in Cairo

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages