Skip to content

Commit 7253441

Browse files
committed
🎨 [BREAKING] refactor: add 'I' as prefix name for interface types
1 parent 6854588 commit 7253441

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+798
-804
lines changed

Diff for: packages/binary-index-tree/src/tree1-mod.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BinaryIndexTree } from './types'
1+
import type { IBinaryIndexTree } from './types'
22
import { lowbit } from './util'
33

44
/**
@@ -16,7 +16,7 @@ import { lowbit } from './util'
1616
export function createBinaryIndexTree1Mod<T extends number | bigint>(
1717
ZERO: T,
1818
MOD: T,
19-
): BinaryIndexTree<T> {
19+
): IBinaryIndexTree<T> {
2020
let _size = 0
2121
const _nodes: T[] = [ZERO]
2222
return { init, add, query }

Diff for: packages/binary-index-tree/src/tree1.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BinaryIndexTree } from './types'
1+
import type { IBinaryIndexTree } from './types'
22
import { lowbit } from './util'
33

44
/**
@@ -9,7 +9,7 @@ import { lowbit } from './util'
99
* @param ZERO 0 for number, 0n for bigint.
1010
* @returns
1111
*/
12-
export function createBinaryIndexTree1<T extends number | bigint>(ZERO: T): BinaryIndexTree<T> {
12+
export function createBinaryIndexTree1<T extends number | bigint>(ZERO: T): IBinaryIndexTree<T> {
1313
let _size = 0
1414
const _nodes: T[] = [ZERO]
1515
return { init, add, query }

Diff for: packages/binary-index-tree/src/tree2-mod.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BinaryIndexTree } from './types'
1+
import type { IBinaryIndexTree } from './types'
22
import { lowbit } from './util'
33

44
/**
@@ -16,7 +16,7 @@ import { lowbit } from './util'
1616
export function createBinaryIndexTree2Mod<T extends number | bigint>(
1717
ZERO: T,
1818
MOD: T,
19-
): BinaryIndexTree<T> {
19+
): IBinaryIndexTree<T> {
2020
let _size = 0
2121
const _nodes: T[] = [ZERO]
2222
return { init, add, query }

Diff for: packages/binary-index-tree/src/tree2.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BinaryIndexTree } from './types'
1+
import type { IBinaryIndexTree } from './types'
22
import { lowbit } from './util'
33

44
/**
@@ -9,7 +9,7 @@ import { lowbit } from './util'
99
* @param ZERO 0 for number, 0n for bigint.
1010
* @returns
1111
*/
12-
export function createBinaryIndexTree2<T extends number | bigint>(ZERO: T): BinaryIndexTree<T> {
12+
export function createBinaryIndexTree2<T extends number | bigint>(ZERO: T): IBinaryIndexTree<T> {
1313
let _size = 0
1414
const _nodes: T[] = [ZERO]
1515

Diff for: packages/binary-index-tree/src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Tree. Its advantage is that the complexity constant is smaller, and the
99
* implementation is simpler and easier to understand.
1010
*/
11-
export interface BinaryIndexTree<T extends number | bigint> {
11+
export interface IBinaryIndexTree<T extends number | bigint> {
1212
/**
1313
* Initialize the binary search tree.
1414
*

Diff for: packages/calculate/src/calculate.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { TokenSymbol, idx, ll1Table, sddTable } from './constant'
2-
import type { Operations } from './operations'
2+
import type { IOperations } from './operations'
33
import { bigintOperations, decimalOperations, integerOperations } from './operations'
44

5-
export type Calculate<T extends number | bigint> = (expression: string) => T
5+
export type ICalculate<T extends number | bigint> = (expression: string) => T
66

77
export function createCalculate<T extends number | bigint>(
8-
operations: Operations<T>,
8+
operations: IOperations<T>,
99
resolveExpression?: (s: string) => string,
10-
): Calculate<T> {
10+
): ICalculate<T> {
1111
const { ZERO, parse, add, subtract, multiply, divide } = operations
1212
return function (rawExpression: string): T {
1313
const expression = resolveExpression == null ? rawExpression : resolveExpression(rawExpression)
@@ -136,16 +136,16 @@ export function createCalculate<T extends number | bigint>(
136136
}
137137

138138
// Integer calculate.
139-
export const calculate: Calculate<number> = createCalculate<number>(integerOperations, s =>
139+
export const calculate: ICalculate<number> = createCalculate<number>(integerOperations, s =>
140140
s.replace(/[\s]+/g, ''),
141141
)
142142

143143
// Decimal calculate.
144-
export const decimalCalculate: Calculate<number> = createCalculate<number>(decimalOperations, s =>
144+
export const decimalCalculate: ICalculate<number> = createCalculate<number>(decimalOperations, s =>
145145
s.replace(/[\s]+/g, '').replace(/(^|[^\d.])\./g, '$10.'),
146146
)
147147

148148
// Bigint calculate.
149-
export const bigintCalculate: Calculate<bigint> = createCalculate<bigint>(bigintOperations, s =>
149+
export const bigintCalculate: ICalculate<bigint> = createCalculate<bigint>(bigintOperations, s =>
150150
s.replace(/[\s]+/g, ''),
151151
)

Diff for: packages/calculate/src/operations.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const DOT_CHAR_CODE = 46
22
const ZERO_CHAR_CODE = 48
33
const NINE_CHAR_CODE = 57
44

5-
export interface Operations<T extends number | bigint = number> {
5+
export interface IOperations<T extends number | bigint = number> {
66
ZERO: T
77
parse(s: string, start: number): [nextStart: number, value: T]
88
add(a: T, b: T): T
@@ -11,7 +11,7 @@ export interface Operations<T extends number | bigint = number> {
1111
divide(a: T, b: T): T
1212
}
1313

14-
export const integerOperations: Operations = {
14+
export const integerOperations: IOperations = {
1515
ZERO: 0,
1616
parse: (s, start) => {
1717
let result = 0
@@ -29,7 +29,7 @@ export const integerOperations: Operations = {
2929
divide: (a, b) => Math.floor(a / b),
3030
}
3131

32-
export const decimalOperations: Operations = {
32+
export const decimalOperations: IOperations = {
3333
ZERO: 0,
3434
parse: (s, start) => {
3535
let i = start
@@ -52,7 +52,7 @@ export const decimalOperations: Operations = {
5252
divide: (a, b) => a / b,
5353
}
5454

55-
export const bigintOperations: Operations<bigint> = {
55+
export const bigintOperations: IOperations<bigint> = {
5656
ZERO: 0n,
5757
parse: (s, start) => {
5858
let i = start

Diff for: packages/dinic/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ The **Dinic** algorithm is an algorithm for solving network flow problems.
6969
yarn add @algorithm.ts/dinic
7070
```
7171

72+
* deno
73+
74+
```typescript
75+
import { createDinic } from 'https://raw.githubusercontent.com/guanghechen/algorithm.ts/main/packages/dinic/src/index.ts'
76+
```
77+
7278
## Usage
7379

7480
* Codeforces contest 1082 Problem G (https://codeforces.com/contest/1082/problem/G):

Diff for: packages/dinic/__test__/__snapshots__/codeforce.spec.ts.snap

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
exports[`codeforces contest 1082 g 1`] = `
44
Array [
55
"edgeTot",
6-
"dist",
76
"edges",
87
"G",
98
]

Diff for: packages/dinic/src/dinic.ts

-102
This file was deleted.

0 commit comments

Comments
 (0)