jc-structure 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +342 -373
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,153 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
export * from "./types/index";
|
|
1
|
+
/// <reference path="./types/index.d.ts" />
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
declare module "jc-structure" {
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* 栈类,采用object实现
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// * 清除数据结构元素
|
|
19
|
-
// */
|
|
20
|
-
// clear(): void;
|
|
21
|
-
// /**
|
|
22
|
-
// * 重写 toString 方法
|
|
23
|
-
// */
|
|
24
|
-
// toString(): string;
|
|
25
|
-
// }
|
|
7
|
+
export class Stack<T> implements IStack<T> {
|
|
8
|
+
constructor();
|
|
9
|
+
pop(): T | undefined;
|
|
10
|
+
push(...args: (T | T[])[]): this;
|
|
11
|
+
peek(): T | undefined;
|
|
12
|
+
isEmpty(): boolean;
|
|
13
|
+
size(): number;
|
|
14
|
+
clear(): void;
|
|
15
|
+
toString(): string;
|
|
16
|
+
}
|
|
26
17
|
|
|
27
18
|
/**
|
|
28
|
-
*
|
|
19
|
+
* 队列类,采用object实现
|
|
29
20
|
*/
|
|
30
|
-
export class
|
|
21
|
+
export class Queue<T> implements IQueue<T> {
|
|
31
22
|
constructor();
|
|
23
|
+
dequeue(): T | undefined;
|
|
24
|
+
enqueue(...args: (T | T[])[]): this;
|
|
25
|
+
front(): T | undefined;
|
|
26
|
+
isEmpty(): boolean;
|
|
27
|
+
size(): number;
|
|
28
|
+
clear(): void;
|
|
29
|
+
toString(): string;
|
|
32
30
|
}
|
|
33
|
-
// interface
|
|
31
|
+
// interface Queue<T> extends DataStructure {
|
|
34
32
|
// /**
|
|
35
|
-
// * ####
|
|
33
|
+
// * #### 移除队列头部元素并返回该元素
|
|
36
34
|
// */
|
|
37
|
-
//
|
|
35
|
+
// dequeue(): T | undefined;
|
|
38
36
|
|
|
39
37
|
// /**
|
|
40
|
-
// * ####
|
|
41
|
-
// * @param args
|
|
38
|
+
// * #### 向队列末尾添加元素
|
|
39
|
+
// * @param args 要添加的元素
|
|
42
40
|
// */
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
// push(...items: T[]): this;
|
|
46
|
-
// push(itemOrItems: T | Array<T>): this;
|
|
47
|
-
|
|
41
|
+
// enqueue(items: T | Array<T>): this;
|
|
42
|
+
// enqueue(...args: Array<T>): this;
|
|
48
43
|
// /**
|
|
49
|
-
// * ####
|
|
44
|
+
// * #### 返回队列头部元素,但不移除
|
|
50
45
|
// */
|
|
51
|
-
//
|
|
46
|
+
// front(): T | undefined;
|
|
52
47
|
// }
|
|
53
|
-
// interface
|
|
54
|
-
// new <T>():
|
|
55
|
-
// readonly prototype:
|
|
48
|
+
// interface QueueConstructor {
|
|
49
|
+
// new <T>(): Queue<T>;
|
|
50
|
+
// readonly prototype: Queue<T>;
|
|
56
51
|
// }
|
|
57
|
-
// var
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 队列类,采用object实现
|
|
61
|
-
*/
|
|
62
|
-
interface Queue<T> extends DataStructure {
|
|
63
|
-
/**
|
|
64
|
-
* #### 移除队列头部元素并返回该元素
|
|
65
|
-
*/
|
|
66
|
-
dequeue(): T | undefined;
|
|
52
|
+
// var Queue: QueueConstructor;
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
* #### 向队列末尾添加元素
|
|
70
|
-
* @param args 要添加的元素
|
|
71
|
-
*/
|
|
72
|
-
enqueue(items: T | Array<T>): this;
|
|
73
|
-
enqueue(...args: Array<T>): this;
|
|
74
|
-
/**
|
|
75
|
-
* #### 返回队列头部元素,但不移除
|
|
76
|
-
*/
|
|
77
|
-
front(): T | undefined;
|
|
78
|
-
}
|
|
79
|
-
interface QueueConstructor {
|
|
80
|
-
new <T>(): Queue<T>;
|
|
81
|
-
readonly prototype: Queue<T>;
|
|
82
|
-
}
|
|
83
|
-
var Queue: QueueConstructor;
|
|
54
|
+
// type CompareResult = -1 | 0 | 1;
|
|
84
55
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
(a: T, b: T): CompareResult;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
interface Obj<V = any> {
|
|
92
|
-
[key: string]: V;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* 最小堆
|
|
96
|
-
*/
|
|
97
|
-
interface MinHeap<T> extends DataStructure {
|
|
98
|
-
/**
|
|
99
|
-
* #### 插入一个值,返回一个布尔值
|
|
100
|
-
* @param value 要插入的值
|
|
101
|
-
*/
|
|
102
|
-
insert(value: T): boolean;
|
|
56
|
+
// interface CompareFn<T> {
|
|
57
|
+
// (a: T, b: T): CompareResult;
|
|
58
|
+
// }
|
|
103
59
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
60
|
+
// interface Obj<V = any> {
|
|
61
|
+
// [key: string]: V;
|
|
62
|
+
// }
|
|
63
|
+
// /**
|
|
64
|
+
// * 最小堆
|
|
65
|
+
// */
|
|
66
|
+
// interface MinHeap<T> extends DataStructure {
|
|
67
|
+
// /**
|
|
68
|
+
// * #### 插入一个值,返回一个布尔值
|
|
69
|
+
// * @param value 要插入的值
|
|
70
|
+
// */
|
|
71
|
+
// insert(value: T): boolean;
|
|
108
72
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
find(): T | undefined;
|
|
114
|
-
}
|
|
115
|
-
interface MinHeapConstructor {
|
|
116
|
-
new <T>(fn?: CompareFn<T>): MinHeap<T>;
|
|
117
|
-
readonly prototype: MinHeap;
|
|
118
|
-
}
|
|
119
|
-
var MinHeap: MinHeapConstructor;
|
|
73
|
+
// /**
|
|
74
|
+
// * #### 移除最小值或最大值,返回该值
|
|
75
|
+
// */
|
|
76
|
+
// extract(): T | undefined;
|
|
120
77
|
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
78
|
+
// /**
|
|
79
|
+
// * 查找一个值
|
|
80
|
+
// * @param value 要查找的值
|
|
81
|
+
// */
|
|
82
|
+
// find(): T | undefined;
|
|
83
|
+
// }
|
|
84
|
+
// interface MinHeapConstructor {
|
|
85
|
+
// new <T>(fn?: CompareFn<T>): MinHeap<T>;
|
|
86
|
+
// readonly prototype: MinHeap;
|
|
87
|
+
// }
|
|
88
|
+
// var MinHeap: MinHeapConstructor;
|
|
89
|
+
|
|
90
|
+
// /**
|
|
91
|
+
// * 最大堆
|
|
92
|
+
// */
|
|
93
|
+
// interface MaxConstructor {
|
|
94
|
+
// new <T>(fn?: CompareFn<T>): MinHeap<T>;
|
|
95
|
+
// readonly prototype: MinHeap<T>;
|
|
96
|
+
// }
|
|
97
|
+
// var MaxHeap: MaxConstructor;
|
|
129
98
|
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
interface LRU<K, V> {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
interface LRUConstructor {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
var LRU: LRUConstructor;
|
|
99
|
+
// /**
|
|
100
|
+
// * LRU缓存类
|
|
101
|
+
// */
|
|
102
|
+
// interface LRU<K, V> {
|
|
103
|
+
// /**
|
|
104
|
+
// * 获取缓存的值
|
|
105
|
+
// * @param key 键值
|
|
106
|
+
// */
|
|
107
|
+
// get(key: K): V | undefined;
|
|
108
|
+
// /**
|
|
109
|
+
// * 更新缓存
|
|
110
|
+
// * @param key 键值
|
|
111
|
+
// * @param value 缓存的值
|
|
112
|
+
// */
|
|
113
|
+
// update(key: K, value: V): void;
|
|
114
|
+
// }
|
|
115
|
+
// interface LRUConstructor {
|
|
116
|
+
// new <K, V>(capacity?: number): LRU<K, V>;
|
|
117
|
+
// readonly prototype: LRU;
|
|
118
|
+
// }
|
|
119
|
+
// var LRU: LRUConstructor;
|
|
151
120
|
|
|
152
121
|
// export class JcNode<T> {
|
|
153
122
|
// value: T;
|
|
@@ -175,277 +144,277 @@ declare module "jc-structure" {
|
|
|
175
144
|
// constructor(elements?: T[]);
|
|
176
145
|
// }
|
|
177
146
|
|
|
178
|
-
export type NodeType<T> = JcNode<T>;
|
|
179
|
-
export type ListType<T> = LinkedList<T>;
|
|
147
|
+
// export type NodeType<T> = JcNode<T>;
|
|
148
|
+
// export type ListType<T> = LinkedList<T>;
|
|
180
149
|
|
|
181
150
|
/**
|
|
182
151
|
* 字典类
|
|
183
152
|
*/
|
|
184
|
-
export class Dictionary<K, V> {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
153
|
+
// export class Dictionary<K, V> {
|
|
154
|
+
// constructor();
|
|
155
|
+
// /**
|
|
156
|
+
// * #### 设置键值对
|
|
157
|
+
// * @param key 键
|
|
158
|
+
// * @param value 值
|
|
159
|
+
// */
|
|
160
|
+
// set(key: K, value: V): void;
|
|
192
161
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
162
|
+
// /**
|
|
163
|
+
// * #### 删除键值对
|
|
164
|
+
// * @param key 键
|
|
165
|
+
// */
|
|
166
|
+
// remove(key: K): ValuePair<K, V> | undefined;
|
|
198
167
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
168
|
+
// /**
|
|
169
|
+
// * #### 判断键是否存在
|
|
170
|
+
// * @param key 键
|
|
171
|
+
// */
|
|
172
|
+
// has(key: K): boolean;
|
|
204
173
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
174
|
+
// /**
|
|
175
|
+
// * #### 获取键值对
|
|
176
|
+
// * @param key 键
|
|
177
|
+
// */
|
|
178
|
+
// get(key: K): ValuePair<K, V> | undefined;
|
|
210
179
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
180
|
+
// /**
|
|
181
|
+
// * #### 获取键数组
|
|
182
|
+
// */
|
|
183
|
+
// keys(): Array<K>;
|
|
215
184
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
185
|
+
// /**
|
|
186
|
+
// * #### 获取值数组
|
|
187
|
+
// */
|
|
188
|
+
// values(): Array<V>;
|
|
220
189
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
190
|
+
// /**
|
|
191
|
+
// * #### 获取键值对数组
|
|
192
|
+
// */
|
|
193
|
+
// keyValues(): Array<[K, V]>;
|
|
225
194
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
195
|
+
// /**
|
|
196
|
+
// * 遍历键值对
|
|
197
|
+
// * @param callbackFunc 回调函数
|
|
198
|
+
// */
|
|
199
|
+
// forEach(callbackFunc: (key: K, value: V) => boolean | void): void;
|
|
231
200
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
201
|
+
// /**
|
|
202
|
+
// * 判断数据结构是否为空
|
|
203
|
+
// */
|
|
204
|
+
// isEmpty(): boolean;
|
|
205
|
+
// /**
|
|
206
|
+
// * 数据结构元素长度
|
|
207
|
+
// */
|
|
208
|
+
// size(): number;
|
|
209
|
+
// /**
|
|
210
|
+
// * 重写 toString 方法
|
|
211
|
+
// */
|
|
212
|
+
// toString(): string;
|
|
213
|
+
// /**
|
|
214
|
+
// * 清除数据结构元素
|
|
215
|
+
// */
|
|
216
|
+
// clear(): void;
|
|
217
|
+
// }
|
|
249
218
|
|
|
250
219
|
/**
|
|
251
220
|
* 图类
|
|
252
221
|
*/
|
|
253
|
-
export class Graph<T> implements IGraph<T> {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
222
|
+
// export class Graph<T> implements IGraph<T> {
|
|
223
|
+
// constructor(isDirected?: boolean);
|
|
224
|
+
// /**
|
|
225
|
+
// * #### 添加顶点的方法
|
|
226
|
+
// * @param v 顶点
|
|
227
|
+
// */
|
|
228
|
+
// addVertex(v: T): void;
|
|
229
|
+
// /**
|
|
230
|
+
// * #### 添加边的方法
|
|
231
|
+
// * @param v 顶点
|
|
232
|
+
// * @param w
|
|
233
|
+
// */
|
|
234
|
+
// addEdge(v: T, w: T): void;
|
|
235
|
+
// /**
|
|
236
|
+
// * #### 获取顶点集合的方法
|
|
237
|
+
// */
|
|
238
|
+
// getVertices(): Array<T>;
|
|
239
|
+
// /**
|
|
240
|
+
// * #### 获取邻接表的方法
|
|
241
|
+
// */
|
|
242
|
+
// getAdjacencyList(): IDictionary<T, Array<T>>;
|
|
243
|
+
// }
|
|
275
244
|
|
|
276
|
-
interface Point {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
interface PointConstructor {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
var Point: PointConstructor;
|
|
245
|
+
// interface Point {
|
|
246
|
+
// /**
|
|
247
|
+
// * #### 点x坐标
|
|
248
|
+
// */
|
|
249
|
+
// readonly x: number;
|
|
250
|
+
// /**
|
|
251
|
+
// * #### 点y坐标
|
|
252
|
+
// */
|
|
253
|
+
// readonly y: number;
|
|
254
|
+
// /**
|
|
255
|
+
// * #### 计算点与点之间的距离,实例方法
|
|
256
|
+
// * @param p 点p
|
|
257
|
+
// */
|
|
258
|
+
// distanceTo(p: Point): number;
|
|
259
|
+
// }
|
|
260
|
+
// interface PointConstructor {
|
|
261
|
+
// new (x: number, y: number): Point;
|
|
262
|
+
// /**
|
|
263
|
+
// * #### 计算两点之间的距离
|
|
264
|
+
// * @param p1 点1
|
|
265
|
+
// * @param p2 点2
|
|
266
|
+
// */
|
|
267
|
+
// distance(p1: Point, p2: Point): number;
|
|
268
|
+
// }
|
|
269
|
+
// var Point: PointConstructor;
|
|
301
270
|
|
|
302
|
-
interface Line {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
interface LineConstructor {
|
|
335
|
-
|
|
336
|
-
|
|
271
|
+
// interface Line {
|
|
272
|
+
// /**
|
|
273
|
+
// * #### 线段长度
|
|
274
|
+
// */
|
|
275
|
+
// get length(): number;
|
|
276
|
+
// /**
|
|
277
|
+
// * #### 线段中点
|
|
278
|
+
// */
|
|
279
|
+
// get midpoint(): Point;
|
|
280
|
+
// /**
|
|
281
|
+
// * #### 线段角度(弧度)
|
|
282
|
+
// */
|
|
283
|
+
// get angle(): number;
|
|
284
|
+
// /**
|
|
285
|
+
// * #### 获取线段的方向向量
|
|
286
|
+
// */
|
|
287
|
+
// get direction(): Point;
|
|
288
|
+
// /**
|
|
289
|
+
// * #### 获取线段的起点
|
|
290
|
+
// */
|
|
291
|
+
// get start(): Point;
|
|
292
|
+
// /**
|
|
293
|
+
// * #### 获取线段的终点
|
|
294
|
+
// */
|
|
295
|
+
// get end(): Point;
|
|
296
|
+
// /**
|
|
297
|
+
// * #### 判断点是否在线段上
|
|
298
|
+
// * @param point
|
|
299
|
+
// * @param tolerance 容差,默认1e-10
|
|
300
|
+
// */
|
|
301
|
+
// containsPoint(point: Point, tolerance?: number): boolean;
|
|
302
|
+
// }
|
|
303
|
+
// interface LineConstructor {
|
|
304
|
+
// new (p1: Point, p2: Point): Line;
|
|
305
|
+
// readonly prototype: Line;
|
|
337
306
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
307
|
+
// /**
|
|
308
|
+
// * #### 判断线段是否平行
|
|
309
|
+
// * @param line 线段
|
|
310
|
+
// * @param tolerance 容差,默认1e-10
|
|
311
|
+
// */
|
|
312
|
+
// sloped(line: Line, tolerance?: number): number | null;
|
|
344
313
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
314
|
+
// /**
|
|
315
|
+
// * #### 判断线段是否平行
|
|
316
|
+
// * @param line1 线段1
|
|
317
|
+
// * @param line2 线段2
|
|
318
|
+
// * @param tolerance 容差,默认1e-10
|
|
319
|
+
// */
|
|
320
|
+
// isParallel(line1: Line, line2: Line, tolerance?: number): boolean;
|
|
352
321
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
322
|
+
// /**
|
|
323
|
+
// * #### 判断线段是否相交
|
|
324
|
+
// * @param line1 线段1
|
|
325
|
+
// * @param line2 线段2
|
|
326
|
+
// */
|
|
327
|
+
// isIntersecting(line1: Line, line2: Line): boolean;
|
|
359
328
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
329
|
+
// /**
|
|
330
|
+
// * #### 获取两线段交点
|
|
331
|
+
// * @param line1 线段1
|
|
332
|
+
// * @param line2 线段2
|
|
333
|
+
// * @param tolerance 容差,默认1e-10
|
|
334
|
+
// */
|
|
335
|
+
// getIntersection(line1: Line, line2: Line, tolerance?: number): Point | null;
|
|
367
336
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
var Line: LineConstructor;
|
|
337
|
+
// /**
|
|
338
|
+
// * #### 获取线段到点的距离
|
|
339
|
+
// * @param line1 线段1
|
|
340
|
+
// * @param line2 线段2
|
|
341
|
+
// * @param tolerance 容差,默认1e-10
|
|
342
|
+
// */
|
|
343
|
+
// distanceToPoint(line: Line, point: Point, tolerance?: number): number;
|
|
344
|
+
// }
|
|
345
|
+
// var Line: LineConstructor;
|
|
377
346
|
|
|
378
|
-
enum TriangleType {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
interface Triangle {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
interface TriangleConstructor {
|
|
421
|
-
|
|
422
|
-
|
|
347
|
+
// enum TriangleType {
|
|
348
|
+
// Equilateral = "equilateral", // 等边
|
|
349
|
+
// Isosceles = "isosceles", // 等腰
|
|
350
|
+
// Scalene = "scalene", // 不等边
|
|
351
|
+
// }
|
|
352
|
+
// /**
|
|
353
|
+
// * ### 三角形类
|
|
354
|
+
// */
|
|
355
|
+
// interface Triangle {
|
|
356
|
+
// readonly p1: Point;
|
|
357
|
+
// readonly p2: Point;
|
|
358
|
+
// readonly p3: Point;
|
|
359
|
+
// /**
|
|
360
|
+
// * #### 获取三角形的边长
|
|
361
|
+
// */
|
|
362
|
+
// get side(): [number, number, number];
|
|
363
|
+
// /**
|
|
364
|
+
// * #### 获取三角形的内心点
|
|
365
|
+
// */
|
|
366
|
+
// get centroid(): Point;
|
|
367
|
+
// /**
|
|
368
|
+
// * #### 获取三角形的外切园心点
|
|
369
|
+
// */
|
|
370
|
+
// get circumcenter(): Point;
|
|
371
|
+
// /**
|
|
372
|
+
// * #### 获取三角形的内切园心点
|
|
373
|
+
// */
|
|
374
|
+
// get incenter(): Point;
|
|
375
|
+
// /**
|
|
376
|
+
// * #### 获取三角形的周长
|
|
377
|
+
// */
|
|
378
|
+
// perimeter(): number;
|
|
379
|
+
// /**
|
|
380
|
+
// * #### 获取三角形的面积
|
|
381
|
+
// */
|
|
382
|
+
// area(): number;
|
|
383
|
+
// /**
|
|
384
|
+
// * #### 判断点是否在三角形内
|
|
385
|
+
// * @param point
|
|
386
|
+
// */
|
|
387
|
+
// containsPoint(point: Point): boolean;
|
|
388
|
+
// }
|
|
389
|
+
// interface TriangleConstructor {
|
|
390
|
+
// new (p1: Point, p2: Point, p3: Point): Triangle;
|
|
391
|
+
// readonly prototype: Triangle;
|
|
423
392
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
393
|
+
// /**
|
|
394
|
+
// * #### 判断三条边是否能构成三角形
|
|
395
|
+
// * @param a
|
|
396
|
+
// * @param b
|
|
397
|
+
// * @param c
|
|
398
|
+
// */
|
|
399
|
+
// isValid(a: number, b: number, c: number): boolean;
|
|
400
|
+
// /**
|
|
401
|
+
// * #### 计算三角形的面积,采用秦九昭公式或叫海伦面积公式
|
|
402
|
+
// * @param a
|
|
403
|
+
// * @param b
|
|
404
|
+
// * @param c
|
|
405
|
+
// */
|
|
406
|
+
// area(a: number, b: number, c: number): number;
|
|
407
|
+
// /**
|
|
408
|
+
// * #### 获取三角形的角度
|
|
409
|
+
// * @param a
|
|
410
|
+
// * @param b
|
|
411
|
+
// * @param c
|
|
412
|
+
// */
|
|
413
|
+
// getAngles(a: number, b: number, c: number): [number, number, number];
|
|
445
414
|
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
var Triangle: TriangleConstructor;
|
|
415
|
+
// getTYpe(a: number, b: number, c: number): TriangleType;
|
|
416
|
+
// }
|
|
417
|
+
// var Triangle: TriangleConstructor;
|
|
449
418
|
|
|
450
419
|
/**
|
|
451
420
|
* ### 向量类
|
|
@@ -1030,7 +999,7 @@ declare module "jc-structure" {
|
|
|
1030
999
|
* @param visited
|
|
1031
1000
|
* @returns
|
|
1032
1001
|
*/
|
|
1033
|
-
deepClone(obj: unknown, visited?: WeakMap): unknown;
|
|
1002
|
+
// deepClone(obj: unknown, visited?: WeakMap): unknown;
|
|
1034
1003
|
}
|
|
1035
1004
|
var Obj: ObjConstructor;
|
|
1036
1005
|
|