- No longer check the boundary of index of elements in the
*_advance
methods, please ensure the range valid by yourself. - Renamed the
VanillaFindset
toFindset
. - Refined the methods, see the
IFindset
,IHeuristicFindset
,IEnhancedFindset
interfaces for more details.
- Added new
Deque
(implemented with linked list). - Refined the methods, see the
IQueue
,ICircularQueue
,IDeque
,IPriorityQueue
interfaces for more details.
- Removed the
UnsafeTrie
, please the useTrie
directly. - No longer check the boundary of index of elements in the
*_advance
methods, please ensure the range valid by yourself. - Refined the methods, removed the UnsafeTrie, see the
ITrie
interfaces for more details.
- This package has been removed, some graph related types moved to @algorithm.ts/graph.types
No breaking changes.
-
Constructor: Only the
INF
props reserved, thefrom
,dist
,inq
,inqTimes
are not supported anymore. -
Get shortest path: no builtin
getShortestPathTo
anymore, call thegetShortestPath
from the@algorithm.ts/graph
instead. -
bellmanFord
returns a structured result instead of a boolean value.export type IBellmanFordResult<C extends number | bigint> = | { // There is at least one negative cycle in the graph, so the shortest path is not existed. hasNegativeCycle: true } | { hasNegativeCycle: false /** * A big number, representing the unreachable cost. */ INF: C /** * Source point */ source: number /** * Record the shortest path parent source point to the specified point. * For example: bestFrom[x] represents the previous position of x in the shortest path * parent the source point to x. */ bestFrom: ReadonlyArray<number> /** * An array recording the shortest distance to the source point. */ dist: ReadonlyArray<C> }
-
createBinaryIndexTree1
is removed, useSingleUpdateIntervalQuery
instead. -
createBinaryIndexTree2
is removed, useSingleUpdateIntervalQuery
instead. -
No builtin modulo binary index tree, perform the modulus operations through customized
add
method:import { SingleUpdateIntervalQuery } from '@algorithm.ts/binary-index-tree' const MOD = 1e9 + 7 const bit = SingleUpdateIntervalQuery<number>({ operator: { ZERO: 0, add: (x, y) => ((x + y) % MOD + MOD) % MOD, }, })
- Renamed to
@algorithm.ts/bipartite-matching
. - Use
new HungarianDfs()
(ornew HungarianBfs()
) instead ofcreateBipartiteGraphMatching
- Renamed to
@algorithm.ts/calculator
. - Use
calculator.calculate(<expression>)
instead ofcalculate(<expression>)
.
This package is removed, use @algorithm.ts/queue
instead.
- Use
.size
instead of.size()
. .end()
is renamed to.back()
..get()
is removed..set()
is removed..isValidIndex()
is removed..isEmpty()
is removed, use.size > 0
instead.
-
dijkstra
returns a structured result instead of a number array.export interface IDijkstraResult<C extends number | bigint> { /** * A big number, representing the unreachable cost. */ INF: C /** * Source point */ source: number /** * Record the shortest path parent source point to the specified point. * For example: bestFrom[x] represents the previous position of x in the shortest path * parent the source point to x. */ bestFrom: ReadonlyArray<number> /** * An array recording the shortest distance to the source point. */ dist: ReadonlyArray<C> }
Removed, use @algorithm.ts/dijkstra
instead.
import { dijkstraBigint } from '@algorithm.ts/dijkstra'
-
Use
new Dinic()
instead ofcreateDinic()
-
.maxFlow()
is renamed to.maxflow()
-
.solve()
is removed, if you want to access the residual network after run the.maxflow()
, you can try to extend theDinic
and export a method such asgetSnapshot()
.class CustomDinic extends Dinic { public getSnapshot() { return { N: this._N, source: this._source, sink: this._sink, G: this.G, edges: this._edges, edgesTot: this._edgesTot, dist: this._dist } } }
- Use
new DancingLinkX({ MAX_N: <number> })
instead ofcreateDLX(<number>)
- Use
new Findset()
instead ofcreateFindset()
. - Use
new HeuristicFindset()
instead ofcreateHeuristicFindset()
. - Use
new EnhancedFindset()
instead ofcreateEnhancedFindset()
. .size(<number>)
is renamed to.count(<number>)
..resetNode(<number>)
is removed.
No breaking changes.
No breaking changes.
- The graph related types is moved to
@algorithm.ts/types
.
buildEncodingTable
is renamed totoEncodingTable
.buildHuffmanTree
is renamed tofromEncodingTable
.createHuffmanTree
is renamed tofromText
.
-
Use
new Isap()
instead ofcreateIsap()
-
.maxFlow()
is renamed to.maxflow()
-
.solve()
is removed, if you want to access the residual network after run the.maxflow()
, you can try to extend theIsap
and export a method such asgetSnapshot()
.class CustomIsap extends Isap { public getSnapshot() { return { N: this._N, source: this._source, sink: this._sink, G: this.G, edges: this._edges, edgesTot: this._edgesTot, dist: this._dist } } }
- Renamed to
@algorithm.ts/shuffle
.
No breaking changes.
This package is removed, use @algorithm.ts/binary-search
instead.
import { lowerBound } from '@algorithm.ts/binary-search'
- Return
number[]
instead ofUint32Array
.
-
Use
new Mcmf()
instead ofcreateMcmf()
-
.minCostMaxFlow()
return an object instead of tuple. -
.solve()
is removed, if you want to access the residual network after run the.maxflow()
, you can try to extend theMcmf
and export a method such asgetSnapshot()
.class CustomMcmf extends Mcmf { public getSnapshot() { return { N: this._N, source: this._source, sink: this._sink, G: this.G, edges: this._edges, edgesTot: this._edgesTot, dist: this._dist } } }
This package is removed, use @algorithm.ts/queue
instead.
- !!! Priority queue is a Min-Heap now (previous version is a Max-Heap).
- Use
.size
instead of.size()
. .top()
is renamed to.front()
..replaceTop(newElement)
is removed, useQ.dequeue(newElement)
instead..isEmpty()
is removed, use.size > 0
instead..collect()
is removed, useArray.from(Q)
instead.
No breaking changes.
- Renamed to
@algorithm.ts/prime
.
-
This package is removed, use
@algorithm.ts/prime
instead.import { sieveTotient } from '@algorithm.ts/prime'
- Use
new SlidingWindow(options)
instead ofcreateSlidingWindow(cmp)
. max()
is removed, usemin()
instead. The sliding-window is maintain the minimum value index now (the previous version will maintain the maximum value in the window).- Rename
moveForward
toforwardRightBoundary
. - Support to move the left boundary of the sliding-window through the new method
forwardLeftBoundary
. init()
is renamed toreset()
, and the parameters is changed to object style.
-
Use one-dimension array to record a sudoku puzzle / solution data. (Previous version were using two-dimension array).
Once you still want to get a two-dimension array, here is an example shows that.
import { toMatrixStyleBoardData } from '@algorithm.ts/sudoku' // Convert the two-dimensional array to one-dimensional array. const puzzle = oldStylePuzzle.flat() solver.solve(puzzle, solution) // Convert the one-dimensional array to two-dimensional array. const oldStyleSolution = toMatrixStyleBoardData(solution)
-
createSudokuBoard()
is renamed tocreateSudokuBoardData()
. -
fillSudokuBoard()
is renamed tofillSudokuBoardData()
. -
copySudokuBoard()
is renamed tocopySudokuBoardData()
. -
checkSudokuSolution
is renamed tocheckSudokuSolution
.
.insert()
is renamed to.set()
..math()
is renamed to.get()
..hasPrefixMatched
is renamed to.hasPrefix()
..init()
is removed, use.clear()
to initialize trie.
-
This package is removed, use
@algorithm.ts/binary-search
instead.import { upperBound } from '@algorithm.ts/binary-search'