Class: Search

Search(startopt, spaceopt, queueopt, maxopt)

Base class for defining declarative, lazy algorithms.

A Search defines a non-executable local process that explores candidate solutions via lazy iteration. Each candidate is produced on-demand through a queue-driven exploration strategy.

Features:

  • Define initial candidates via from
  • Describe expansion of candidates via through
  • Control exploration order with via
  • Limit branching using max

Transformation and termination are fluent, leveraging methods from Each.

Constructor

Create a new Search instance.

Parameters:
Name Type Attributes Description
start Iterable <optional>

Initial candidates.

space function <optional>

Expansion function.

queue Object <optional>

Queue instance controlling iteration order.

max number <optional>

Maximum queue size.

Classes

Search

Members

max :number|undefined

Maximum queue size (limits branching).

Type:
  • number | undefined

queue :Object

Queue controlling search order (BFS, DFS, priority, etc.). Must implement .addAll(), .poll(), .clear(), .n(), and optionally .select().

Type:
  • Object

space :function|undefined

Expansion function describing the search space. Should return an iterable of new candidates or undefined to stop expansion.

Type:
  • function | undefined

start :Iterable|undefined

Initial candidates to seed the search.

Type:
  • Iterable | undefined

Methods

from(…starts) → {Search}

Define the starting candidates for the search.

Parameters:
Name Type Attributes Description
starts * <repeatable>

One or more initial candidates.

Returns:

The current search instance (for chaining).

Type
Search

through(space) → {Search}

Define the expansion logic (search space).

Parameters:
Name Type Description
space function

Function describing the search space.

Returns:

The current search instance (for chaining).

Type
Search

via(queue, maxopt) → {Search}

Define the queue strategy and optionally set a new maximum size.

Parameters:
Name Type Attributes Description
queue Object

Queue implementation controlling exploration order.

max number <optional>

Optional new maximum queue size.

Returns:

The current search instance (for chaining).

Type
Search