Skip to content

nikollamalic/sol-data-structures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solidity Data Structures

Uses Foundry

This repository contains the implementation of the following data structures in Solidity:

  • Linked List

Linked List

Feel free to update the node value to your liking. Currently it is uint256 but can be anything (structs too!). In case you want to do some inner updates on struct elements remember to load getAt values into storage instead of memory.

Usage example:

contract SomeContract {
    using LinkedList for LinkedList.List;
    LinkedList.List list;

    function add(uint256 value) public {
        list.add(value);
    }

    function remove(uint256 index) public {
        list.remove(index);
    }

    function getAt(uint256 index) public view returns (uint256) {
        return list.getAt(index);
    }

    function traverse() public view returns (uint256[] memory) {
        return list.traverse();
    }
}

About

Contains Solidity data structures

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors