You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

@byte-this/collections

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@byte-this/collections

A library which contains collection objects such as SortedArray

1.0.51
latest
77

Supply Chain Security

100

Vulnerability

83

Quality

77

Maintenance

100

License

Unpopular package

Quality

This package is not very popular.

Found 1 instance in 1 package

Version published
Maintainers
1
Created

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.

FAQs

Package last updated on 07 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts