raptor
    Preparing search index...

    Class Bag<T>

    A bag, i.e. a set using a custom comparison function, keeping only minimal values.

    Warning: once added, elements in the set should not change -- no comparison and filtering would be done in such a case.

    Type Parameters

    • T extends Comparable<T>
    Index

    Constructors

    • Type Parameters

      • T extends Comparable<T>

      Returns Bag<T>

    Properties

    inner: { dominated: boolean; val: T }[] = []

    Accessors

    Methods

    • Adds (O(n^2)) an element in the bag, keeping only minimal values.

      Parameters

      • el: T

        Element to add in the bag

      Returns { added: boolean; pruned: number }

      Wether the element has been added or not, the number of pruned elements

    • Adds (O(n)) an element in the bag, marking new dominated values but not removing them, see add.

      Parameters

      • el: T

        Element to add in the bag

      Returns boolean

      Wether the element has been added or not

    • adds (O(n^2)) everything from another bag in this bag.

      Parameters

      • b: Bag<T>

        Bag to merge from

      Returns { added: number; pruned: number }

      Number of added and pruned elements

    • Updates an element in the bag, removing it if it's being dominated, and removing possible dominated elements

      Parameters

      • oldEl: T

        Element to update currently in the bag

      • newEl: T

        New element to put in its place

      Returns number

      Number of pruned elements, possibly including the updated element

    • Updates an element in the bag, marking dominated elements

      Parameters

      • oldEl: T

        Element to update currently in the bag

      • newEl: T

        New element to put in its place

      Returns boolean

      Wether the updated element is now dominated or not

    • Create (O(n)) a new bag from another. Does NOT copy elements -- they have the same reference.

      Type Parameters

      • T extends Comparable<T>

      Parameters

      Returns Bag<T>