Skip to content

EO Objects for Manipulating with Lists, Maps, Sets, Stacks, Vectors, etc.

License

Notifications You must be signed in to change notification settings

objectionary/eo-collections

Repository files navigation

logo

EO principles respected here DevOps By Rultor.com We recommend IntelliJ IDEA

mvn PDD status codecov Maven Central

Hits-of-Code Lines of code License

EO objects for collections. The abstractions of lists, maps, sets, and others.

This is how it works:

eq. > @
  with.
    QQ.collections.list
      * 1 2
    3
  QQ.collections.list
    * 1 2 3

List

The object QQ.collections.list is a decorator of QQ.array.

The attribute is-empty is TRUE if the length of the array is zero.

The attribute eq is TRUE if each element of the array is equal to the corresponding element of another array and the lengths of both arrays are the same.

The attribute without is a new array with the i-th element removed.

The attributes each, reduce, and map are respectively similar to forEach, reduce, find, reduce, and map methods of Array object in JavaScript (ECMA, 2011). A few “twin” attributes reducedi, and mappediare semantically the same, but with an extra int argument as a counter of a cycle. The attribute slice is a part of the array.

[] > list-test
  QQ.hamcrest.assert-that > @
    reducedi.
      QQ.collections.list
        * TRUE TRUE FALSE
      TRUE
      [a i x]
        and. > @
          x
          a
    $.equal-to FALSE

Map

The object QQ.collections.map is a decorator of QQ.array of pairs (k, v). The map ensures that all k are always unique. It is expected that each k has as-hash attribute that behaves as int. The attributes with, without, found, and foundi are reimplemented in map.

[] > map-test
  QQ.hamcrest.assert-that > @
    at.
      found.
        with.
          QQ.collections.map *
          1
          "a"
        1
      0
    $.equal-to "a"

How to Contribute

Fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run full Maven build:

$ mvn clean install -Pqulice

You will need Maven 3.3+ and Java 8+.