1.0.51 • Published 2 years ago

@byte-this/collections v1.0.51

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

collections

A library which provides different collection objects, such as SortedArray

Coverage lines Coverage functions Coverage branches Coverage statements

SortedList + SortedArray

The SortedArray implementation, based on the SortedList abstraction, lets us work with a list which is sorted at all times. Thus, we can perform retrievals using binary search in O(logn) time instead of O(n) time. The abstraction is based on three main concepts:

  • ComparableType: the minimum type definition needed to run a comparison against two elements in the list.
  • DataType: the full data type to be stored in the list. Default value is equal to ComparableType.
  • Comparer: a callback which will accept two instances of ComparableType and return a number indicating their relative order.

SortedArray will take 1-2 arguments in its constructor:

  • Comparer: function which will compare two of its items
  • InitialList: an initial iterable which we can use to initialize this array

Default Comparers

The following comparers are available as static methods on the SortedArray class:

  • compareNumbers: compare as a - b,
  • compareStrings: compare as a.localeCompare(b)
  • compareDates: compare as +a - +b
  • compareFromComparable: compare as a.compareTo(b)**, anything which implements the iComparable* interface
  • compareFromProperty: we can compare based on a single property which exists on ComparableType with the given comparer method

Equality Set

The EqualitySet implementation extends the SortedArray and provides the additional benefit that only unique items will be added to the set. The instance is constructed in the same way that a SortedArray is.

Graph and Tree

All type definitions for the Graph and Tree (which is based on Graph implementation) can be found in the models folder.

Project Notes

The graph implementation is a bit messy. Other implementations are fine.

1.0.49

2 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.16

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.22

2 years ago

1.0.43

2 years ago

1.0.21

2 years ago

1.0.42

2 years ago

1.0.20

2 years ago

1.0.41

2 years ago

1.0.48

2 years ago

1.0.26

2 years ago

1.0.47

2 years ago

1.0.25

2 years ago

1.0.46

2 years ago

1.0.24

2 years ago

1.0.45

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.15

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago