Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve installExtensionObjectVariables
- Loading branch information
1 parent
645774e
commit 105dc85
Showing
11 changed files
with
698 additions
and
109 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
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
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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
|
||
|
||
|
||
export class IndexIterator { | ||
|
||
public current: number[] | null = null; | ||
constructor(private limits: number[]) { | ||
this.reset(); | ||
} | ||
public reset() { | ||
this.current = []; | ||
for (let i = 0; i < this.limits.length; i++) { | ||
this.current[i] = 0; | ||
} | ||
} | ||
public increment() { | ||
if (!this.current) return; | ||
|
||
|
||
const increase = (n: number): boolean => { | ||
if (n < 0) { | ||
return false; | ||
} | ||
if (!this.current) return false; | ||
if (this.current[n] + 1 >= this.limits[n]) { | ||
if (n==0) { | ||
this.current = null; | ||
return false; | ||
} | ||
this.current[n] = 0; | ||
return increase(n - 1); | ||
} | ||
this.current[n] = this.current[n] + 1; | ||
return true; | ||
} | ||
const n = this.limits.length - 1; | ||
if (!increase(n)) { | ||
this.current = null; | ||
} | ||
} | ||
public next(): number[] { | ||
if (!this.current) { | ||
throw new Error("Outof bond"); | ||
} | ||
const r = [... this.current]; | ||
this.increment(); | ||
return r; | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.