jc-structure 0.2.7 → 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 +340 -374
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,156 +1,122 @@
|
|
|
1
1
|
/// <reference path="./types/index.d.ts" />
|
|
2
2
|
|
|
3
3
|
declare module "jc-structure" {
|
|
4
|
-
import * as Types from "./types";
|
|
5
|
-
export = Types;
|
|
6
|
-
|
|
7
|
-
//#region data structure
|
|
8
4
|
/**
|
|
9
|
-
*
|
|
5
|
+
* 栈类,采用object实现
|
|
10
6
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// * 清除数据结构元素
|
|
22
|
-
// */
|
|
23
|
-
// clear(): void;
|
|
24
|
-
// /**
|
|
25
|
-
// * 重写 toString 方法
|
|
26
|
-
// */
|
|
27
|
-
// toString(): string;
|
|
28
|
-
// }
|
|
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
|
+
}
|
|
29
17
|
|
|
30
18
|
/**
|
|
31
|
-
*
|
|
19
|
+
* 队列类,采用object实现
|
|
32
20
|
*/
|
|
33
|
-
export class
|
|
21
|
+
export class Queue<T> implements IQueue<T> {
|
|
34
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;
|
|
35
30
|
}
|
|
36
|
-
// interface
|
|
31
|
+
// interface Queue<T> extends DataStructure {
|
|
37
32
|
// /**
|
|
38
|
-
// * ####
|
|
33
|
+
// * #### 移除队列头部元素并返回该元素
|
|
39
34
|
// */
|
|
40
|
-
//
|
|
35
|
+
// dequeue(): T | undefined;
|
|
41
36
|
|
|
42
37
|
// /**
|
|
43
|
-
// * ####
|
|
44
|
-
// * @param args
|
|
38
|
+
// * #### 向队列末尾添加元素
|
|
39
|
+
// * @param args 要添加的元素
|
|
45
40
|
// */
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
// push(...items: T[]): this;
|
|
49
|
-
// push(itemOrItems: T | Array<T>): this;
|
|
50
|
-
|
|
41
|
+
// enqueue(items: T | Array<T>): this;
|
|
42
|
+
// enqueue(...args: Array<T>): this;
|
|
51
43
|
// /**
|
|
52
|
-
// * ####
|
|
44
|
+
// * #### 返回队列头部元素,但不移除
|
|
53
45
|
// */
|
|
54
|
-
//
|
|
46
|
+
// front(): T | undefined;
|
|
55
47
|
// }
|
|
56
|
-
// interface
|
|
57
|
-
// new <T>():
|
|
58
|
-
// readonly prototype:
|
|
48
|
+
// interface QueueConstructor {
|
|
49
|
+
// new <T>(): Queue<T>;
|
|
50
|
+
// readonly prototype: Queue<T>;
|
|
59
51
|
// }
|
|
60
|
-
// var
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* 队列类,采用object实现
|
|
64
|
-
*/
|
|
65
|
-
interface Queue<T> extends DataStructure {
|
|
66
|
-
/**
|
|
67
|
-
* #### 移除队列头部元素并返回该元素
|
|
68
|
-
*/
|
|
69
|
-
dequeue(): T | undefined;
|
|
52
|
+
// var Queue: QueueConstructor;
|
|
70
53
|
|
|
71
|
-
|
|
72
|
-
* #### 向队列末尾添加元素
|
|
73
|
-
* @param args 要添加的元素
|
|
74
|
-
*/
|
|
75
|
-
enqueue(items: T | Array<T>): this;
|
|
76
|
-
enqueue(...args: Array<T>): this;
|
|
77
|
-
/**
|
|
78
|
-
* #### 返回队列头部元素,但不移除
|
|
79
|
-
*/
|
|
80
|
-
front(): T | undefined;
|
|
81
|
-
}
|
|
82
|
-
interface QueueConstructor {
|
|
83
|
-
new <T>(): Queue<T>;
|
|
84
|
-
readonly prototype: Queue<T>;
|
|
85
|
-
}
|
|
86
|
-
var Queue: QueueConstructor;
|
|
87
|
-
|
|
88
|
-
type CompareResult = -1 | 0 | 1;
|
|
89
|
-
|
|
90
|
-
interface CompareFn<T> {
|
|
91
|
-
(a: T, b: T): CompareResult;
|
|
92
|
-
}
|
|
54
|
+
// type CompareResult = -1 | 0 | 1;
|
|
93
55
|
|
|
94
|
-
interface
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* 最小堆
|
|
99
|
-
*/
|
|
100
|
-
interface MinHeap<T> extends DataStructure {
|
|
101
|
-
/**
|
|
102
|
-
* #### 插入一个值,返回一个布尔值
|
|
103
|
-
* @param value 要插入的值
|
|
104
|
-
*/
|
|
105
|
-
insert(value: T): boolean;
|
|
56
|
+
// interface CompareFn<T> {
|
|
57
|
+
// (a: T, b: T): CompareResult;
|
|
58
|
+
// }
|
|
106
59
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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;
|
|
111
72
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
find(): T | undefined;
|
|
117
|
-
}
|
|
118
|
-
interface MinHeapConstructor {
|
|
119
|
-
new <T>(fn?: CompareFn<T>): MinHeap<T>;
|
|
120
|
-
readonly prototype: MinHeap;
|
|
121
|
-
}
|
|
122
|
-
var MinHeap: MinHeapConstructor;
|
|
73
|
+
// /**
|
|
74
|
+
// * #### 移除最小值或最大值,返回该值
|
|
75
|
+
// */
|
|
76
|
+
// extract(): T | undefined;
|
|
123
77
|
|
|
124
|
-
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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;
|
|
132
98
|
|
|
133
|
-
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
interface LRU<K, V> {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
interface LRUConstructor {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
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;
|
|
154
120
|
|
|
155
121
|
// export class JcNode<T> {
|
|
156
122
|
// value: T;
|
|
@@ -178,277 +144,277 @@ declare module "jc-structure" {
|
|
|
178
144
|
// constructor(elements?: T[]);
|
|
179
145
|
// }
|
|
180
146
|
|
|
181
|
-
export type NodeType<T> = JcNode<T>;
|
|
182
|
-
export type ListType<T> = LinkedList<T>;
|
|
147
|
+
// export type NodeType<T> = JcNode<T>;
|
|
148
|
+
// export type ListType<T> = LinkedList<T>;
|
|
183
149
|
|
|
184
150
|
/**
|
|
185
151
|
* 字典类
|
|
186
152
|
*/
|
|
187
|
-
export class Dictionary<K, V> {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
153
|
+
// export class Dictionary<K, V> {
|
|
154
|
+
// constructor();
|
|
155
|
+
// /**
|
|
156
|
+
// * #### 设置键值对
|
|
157
|
+
// * @param key 键
|
|
158
|
+
// * @param value 值
|
|
159
|
+
// */
|
|
160
|
+
// set(key: K, value: V): void;
|
|
195
161
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
162
|
+
// /**
|
|
163
|
+
// * #### 删除键值对
|
|
164
|
+
// * @param key 键
|
|
165
|
+
// */
|
|
166
|
+
// remove(key: K): ValuePair<K, V> | undefined;
|
|
201
167
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
168
|
+
// /**
|
|
169
|
+
// * #### 判断键是否存在
|
|
170
|
+
// * @param key 键
|
|
171
|
+
// */
|
|
172
|
+
// has(key: K): boolean;
|
|
207
173
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
174
|
+
// /**
|
|
175
|
+
// * #### 获取键值对
|
|
176
|
+
// * @param key 键
|
|
177
|
+
// */
|
|
178
|
+
// get(key: K): ValuePair<K, V> | undefined;
|
|
213
179
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
180
|
+
// /**
|
|
181
|
+
// * #### 获取键数组
|
|
182
|
+
// */
|
|
183
|
+
// keys(): Array<K>;
|
|
218
184
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
185
|
+
// /**
|
|
186
|
+
// * #### 获取值数组
|
|
187
|
+
// */
|
|
188
|
+
// values(): Array<V>;
|
|
223
189
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
190
|
+
// /**
|
|
191
|
+
// * #### 获取键值对数组
|
|
192
|
+
// */
|
|
193
|
+
// keyValues(): Array<[K, V]>;
|
|
228
194
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
195
|
+
// /**
|
|
196
|
+
// * 遍历键值对
|
|
197
|
+
// * @param callbackFunc 回调函数
|
|
198
|
+
// */
|
|
199
|
+
// forEach(callbackFunc: (key: K, value: V) => boolean | void): void;
|
|
234
200
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
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
|
+
// }
|
|
252
218
|
|
|
253
219
|
/**
|
|
254
220
|
* 图类
|
|
255
221
|
*/
|
|
256
|
-
export class Graph<T> implements IGraph<T> {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
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
|
+
// }
|
|
278
244
|
|
|
279
|
-
interface Point {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
interface PointConstructor {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
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;
|
|
304
270
|
|
|
305
|
-
interface Line {
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
interface LineConstructor {
|
|
338
|
-
|
|
339
|
-
|
|
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;
|
|
340
306
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
307
|
+
// /**
|
|
308
|
+
// * #### 判断线段是否平行
|
|
309
|
+
// * @param line 线段
|
|
310
|
+
// * @param tolerance 容差,默认1e-10
|
|
311
|
+
// */
|
|
312
|
+
// sloped(line: Line, tolerance?: number): number | null;
|
|
347
313
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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;
|
|
355
321
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
322
|
+
// /**
|
|
323
|
+
// * #### 判断线段是否相交
|
|
324
|
+
// * @param line1 线段1
|
|
325
|
+
// * @param line2 线段2
|
|
326
|
+
// */
|
|
327
|
+
// isIntersecting(line1: Line, line2: Line): boolean;
|
|
362
328
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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;
|
|
370
336
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
379
|
-
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;
|
|
380
346
|
|
|
381
|
-
enum TriangleType {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
interface Triangle {
|
|
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
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
423
|
-
interface TriangleConstructor {
|
|
424
|
-
|
|
425
|
-
|
|
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;
|
|
426
392
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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];
|
|
448
414
|
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
var Triangle: TriangleConstructor;
|
|
415
|
+
// getTYpe(a: number, b: number, c: number): TriangleType;
|
|
416
|
+
// }
|
|
417
|
+
// var Triangle: TriangleConstructor;
|
|
452
418
|
|
|
453
419
|
/**
|
|
454
420
|
* ### 向量类
|
|
@@ -1033,7 +999,7 @@ declare module "jc-structure" {
|
|
|
1033
999
|
* @param visited
|
|
1034
1000
|
* @returns
|
|
1035
1001
|
*/
|
|
1036
|
-
deepClone(obj: unknown, visited?: WeakMap): unknown;
|
|
1002
|
+
// deepClone(obj: unknown, visited?: WeakMap): unknown;
|
|
1037
1003
|
}
|
|
1038
1004
|
var Obj: ObjConstructor;
|
|
1039
1005
|
|