-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
138 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
|
||
export class Dict<T>{ | ||
private data: any; | ||
private num:number; | ||
|
||
constructor() { | ||
this.data = {}; | ||
this.num = 0; | ||
} | ||
private data: any; | ||
private num: number; | ||
|
||
public add(key: string, val: T) { | ||
this.data[key] = val; | ||
this.num++; | ||
} | ||
constructor() { | ||
this.data = {}; | ||
this.num = 0; | ||
} | ||
|
||
public find(key: string): T { | ||
return this.data[key]; | ||
} | ||
public add(key: string, val: T) { | ||
this.data[key] = val; | ||
this.num++; | ||
} | ||
|
||
public remove(key: string) { | ||
delete this.data[key]; | ||
this.num--; | ||
} | ||
public find(key: string): T { | ||
return this.data[key]; | ||
}ßßß | ||
|
||
public clear() { | ||
for (let k in this.data) { | ||
delete this.data[k]; | ||
} | ||
this.num = 0; | ||
} | ||
public remove(key: string) { | ||
delete this.data[key]; | ||
this.num--; | ||
} | ||
|
||
public count(): number { | ||
return Object.keys(this.data).length; | ||
public clear() { | ||
for (let k in this.data) { | ||
delete this.data[k]; | ||
} | ||
this.num = 0; | ||
} | ||
|
||
public count(): number { | ||
return Object.keys(this.data).length; | ||
} | ||
|
||
public display() { | ||
for(let k in this.data) { | ||
console.log(k," => ", this.data[k]); | ||
} | ||
public display() { | ||
for (let k in this.data) { | ||
console.log(k, " => ", this.data[k]); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.