Skip to content

grappafinance/array-lib

Repository files navigation

Array Util

Library for Array


Lib for solidity arrays.

Installation

forge install grappafinance/array-lib@v0.1.0 --no-commit

Add to remapping.txt

array-lib=lib/array-lib/src

Usage

Array Utils

import {UintArrayLib} from "array-lib/UintArrayLib.sol";

using UintArrayLib for uint256[];

function zeroSum(uint256[] memory arr) internal pure returns (bool) {
  return arr.sum() == 0;
}

Sorting

import {QuickSort} from "array-lib/sorting/QuickSort.sol";

using QuickSort for uint256[];

function calculateSomethingHard() internal pure returns (bool) {
  uint256[] memory arr = _getArr();

  // get a new sorting array
  uint256[] sorted = arr.getSorted();

  // sort in memory
  arr.sort();

  
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages