新增fastList、注释完善

This commit is contained in:
yhh
2020-10-27 18:08:49 +08:00
parent 0e7b0bc45c
commit fc6a8a0803
19 changed files with 595 additions and 205 deletions

View File

@@ -0,0 +1,17 @@
module es {
export class EqualityComparer<T> implements IEqualityComparer {
public static default<T>(){
return new EqualityComparer<T>();
}
protected constructor(){ }
public equals(x: T, y: T): boolean{
if (typeof x["equals"] == 'function'){
return x["equals"](y);
} else {
return x === y;
}
}
}
}

View File

@@ -0,0 +1,5 @@
module es {
export interface IComparer<T>{
compare(x: T, y: T): number;
}
}

View File

@@ -0,0 +1,5 @@
module es {
export interface IEqualityComparer {
equals(x: any, y: any): boolean;
}
}

View File

@@ -0,0 +1,8 @@
module es {
/**
* 实现该接口用于判定两个对象是否相等的快速接口
*/
export interface IEquatable<T> {
equals(other: T): boolean;
}
}

View File

@@ -2,7 +2,7 @@ module es {
/**
* 用于管理一对对象的简单DTO
*/
export class Pair<T> {
export class Pair<T> implements IEquatable<Pair<T>> {
public first: T;
public second: T;
@@ -15,7 +15,8 @@ module es {
this.first = this.second = null;
}
public equals(other: Pair<T>) {
public equals(other: Pair<T>): boolean {
// 这两种方法在功能上应该是等价的
return this.first == other.first && this.second == other.second;
}
}