hxSet

simple set class


Keywords
cross
License
BSD-3-Clause
Install
haxelib install hxSet 1.5.0

Documentation

hxSet
-----

This is a simple 'set' class.  It supports basic set operations.  It is implemented with a list.

length
        property that tells the number of items in the set

new()
        create an empty set

add(item :T, ?cmp :T->T->Bool) :Bool
        add an item to the set
        returns true if it was added

remove(pred :T->Bool) :Int
       remove items from the set that are selected by the given predicate
       returns the number of items removed

has(item :T, ?cmp :T->T->Bool)
        returns true if the given item is in the set

isEmpty()
        returns true if the set is empty

union(otherItems :Iterable<T>, ?cmp :T->T->Bool) :Int
        add the items from the given iterable to the set
        returns the number of items added

intersection(otherItems :Iterable<T>, ?cmp :T->T->Bool) :Int
        remove items which are not in the given iterable
        returns the number of items removed

minus(otherItems :Iterable<T>, ?cmp :T->T->Bool) :Int
        remove items what are in given iterable
        return the number of items removed

equals(otherSet :Set<T>, ?cmp :T->T->Bool) :Bool
        check if sets are equal (made up of the same items).  pass in a cmp function to override item comparison. O(n^2).
        return true if both sets contain the same (or equivalent if cmp is provided) items

clear()
        empty the set

iterator()
        iterate over items in the set.  order will be filo.