cryptofin-solidity

cryptofin-solidity

  • Docs
  • Blog

›ARRAY-UTILS

ARRAY-UTILS

  • AddressArrayUtils
  • UIntArrayUtils

RATIONALS

  • Rational
  • RationalMath

UNCATEGORIZED

  • Migrations

AddressArrayUtils

library AddressArrayUtils

Source: array-utils/AddressArrayUtils.sol

Index

  • append
  • argGet
  • contains
  • difference
  • extend
  • hasDuplicate
  • indexOf
  • indexOfFromEnd
  • intersect
  • isEqual
  • pop
  • remove
  • sExtend
  • sPop
  • sPopCheap
  • sRemoveCheap
  • sReverse
  • union
  • unionB

Reference

Functions

  • append

    function append(address[] A, address a) internal pure returns (address[])

    Returns the array with a appended to A.

    Parameters:
    A - The first array
    a - The value to append
    Returns:
    Returns A appended by a
  • argGet

    function argGet(address[] A, uint256[] indexArray) internal pure returns (address[])

    Returns the elements indexed at indexArray.

    Parameters:
    A - The array to index
    indexArray - The array to use to index
    Returns:
    Returns array containing elements indexed at indexArray
  • contains

    function contains(address[] A, address a) internal pure returns (bool)

    Returns true if the value is present in the list. Uses indexOf internally.

    Parameters:
    A - The input array to search
    a - The value to find
    Returns:
    Returns isIn for the first occurrence starting from index 0
  • difference

    function difference(address[] A, address[] B) internal pure returns (address[])

    Computes the difference of two arrays. Assumes there are no duplicates.

    Parameters:
    A - The first array
    B - The second array
    Returns:
    The difference of the two arrays
  • extend

    function extend(address[] A, address[] B) internal pure returns (address[])

    Returns the combination of the two arrays.

    Parameters:
    A - The first array
    B - The second array
    Returns:
    Returns A extended by B
  • hasDuplicate

    function hasDuplicate(address[] A) internal pure returns (bool)

    Returns whether or not there's a duplicate. Runs in O(n^2).

    Parameters:
    A - Array to search
    Returns:
    Returns true if duplicate, false otherwise
  • indexOf

    function indexOf(address[] A, address a) internal pure returns (uint256, bool)

    Finds the index of the first occurrence of the given element.

    Parameters:
    A - The input array to search
    a - The value to find
    Returns:
    Returns (index and isIn) for the first occurrence starting from index 0
  • indexOfFromEnd

    function indexOfFromEnd(address[] A, address a) internal pure returns (uint256, bool)
    Parameters:
    A - address[]
    a - address
    Returns:
    Returns index and isIn for the first occurrence starting from end
  • intersect

    function intersect(address[] A, address[] B) internal pure returns (address[])

    Returns the intersection of two arrays. Arrays are treated as collections, so duplicates are kept.

    Parameters:
    A - The first array
    B - The second array
    Returns:
    The intersection of the two arrays
  • isEqual

    function isEqual(address[] A, address[] B) internal pure returns (bool)

    Returns whether the two arrays are equal.

    Parameters:
    A - The first array
    B - The second array
    Returns:
    True is the arrays are equal, false if not.
  • pop

    function pop(address[] A, uint256 index) internal pure returns (address[], address)

    Removes specified index from array Resulting ordering is not guaranteed.

    Parameters:
    A - address[]
    index - uint256
    Returns:
    Returns the new array and the removed entry
  • remove

    function remove(address[] A, address a) internal pure returns (address[])
    Parameters:
    A - address[]
    a - address
    Returns:
    Returns the new array
  • sExtend

    function sExtend(address[] A, address[] B) internal

    Returns the combination of two storage arrays.

    Parameters:
    A - The first array
    B - The second array
    Returns:
    Returns A appended by a
  • sPop

    function sPop(address[] A, uint256 index) internal returns (address)
    Parameters:
    A - address[]
    index - uint256
    Returns:
    address
  • sPopCheap

    function sPopCheap(address[] A, uint256 index) internal returns (address)

    Deletes address at index and fills the spot with the last address. Order is not preserved.

    Parameters:
    A - address[]
    index - uint256
    Returns:
    Returns the removed entry
  • sRemoveCheap

    function sRemoveCheap(address[] A, address a) internal

    Deletes address at index. Works by swapping it with the last address, then deleting. Order is not preserved.

    Parameters:
    A - Storage array to remove from
    a - address
  • sReverse

    function sReverse(address[] A) internal

    Reverses storage array in place.

    Parameters:
    A - address[]
  • union

    function union(address[] A, address[] B) internal pure returns (address[])

    Returns the union of the two arrays. Order is not guaranteed.

    Parameters:
    A - The first array
    B - The second array
    Returns:
    The union of the two arrays
  • unionB

    function unionB(address[] A, address[] B) internal pure returns (address[])

    Alternate implementation Assumes there are no duplicates.

    Parameters:
    A - address[]
    B - address[]
    Returns:
    address[]
UIntArrayUtils →
cryptofin-solidity
Community
TelegramTwitter
More
BlogGitHubStar
Copyright © 2018 CryptoFin