Maintains a bidirectional mapping between product IDs and shape IDs.

This class allows efficient querying of all shapes associated with a product, all products associated with a shape, and iteration over all unique product-shape pairs.

  • Each product ID/product def can be associated with multiple shape IDs, and vice versa.
  • It is expected that a product ID and product definition ID are map a singular product to one or more product definitions, but that there is only a singular constnat product ID for a given product definition ID.
  • The mapping is idempotent: adding the same product-shape pair multiple times has no effect after the first addition.
  • The total count reflects the number of unique product-shape pairs.

Constructors

Accessors

  • get count(): number
  • Returns the number of unique product-shape pairs.

    Returns number

    The count of unique product-shape pairs.

Methods

  • Adds a mapping between a product and its product definition to a shape. If the product def share pair does not already exist, it is added to both the product-to-shapes and shape-to-products maps, and the internal count is incremented.

    Parameters

    • productId: number

      The local ID of the product.

    • productDefitionId: number

      The local ID of the product definition.

    • shapeId: number

      The local ID of the shape.

    Returns boolean

    if the pair was newly added; false if the pair already existed.

  • Gets the set of product ids for a given shape id.

    Parameters

    • shapeId: number

      Shape numerical id

    Returns undefined | Set<number>

    A set of product ids associated with the shape, or undefined if no products are associated.

  • Get the s for a shape, given the shape local ID.

    Parameters

    • shapeId: number

      The local ID of the shape.

    Returns undefined | Set<number>

    The local IDs of the product definition associated with the shape, or undefined if no product definition is associated with the shape.

  • Gets the set of shape ids for a given product id.

    Parameters

    • productId: number

      Product numerical id

    Returns undefined | Set<number>

    A set of shape ids associated with the product, or undefined if no shapes are associated.

  • Get the ids of products mapped to their associated shapes.

    Returns IterableIterator<[number, Set<number>], any, any>

    Returns an iterator of [productId, Set] pairs.

  • Get the ids of product defs mapped to their associated products.

    Returns IterableIterator<[number, Set<number>], any, any>

    Returns an iterator of [productId, Set] pairs.

  • Returns an iterator of [shapeId, Set] pairs.

    Returns IterableIterator<[number, Set<number>], any, any>

    Returns an iterator of [shapeId, Set] pairs.

  • Returns an iterator of all unique [productId productDefinitionId, shapeId] tuples.

    Returns IterableIterator<[number, number, number], any, any>

    An iterator of unique product-shape tuples.