Skip to content

Commit

Permalink
refactor(vectors): add StridedVec, update IVector, AVec
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Nov 30, 2018
1 parent d381ace commit 25b9789
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
21 changes: 12 additions & 9 deletions packages/vectors3/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@ export interface Vec extends
[id: number]: number;
}

export interface IVector<T> extends
Vec,
ICopy<T>,
IEmpty<T>,
IEqualsDelta<T> {
export interface ReadonlyVec extends
Iterable<number>,
ILength {
readonly [id: number]: number;
}

export interface StridedVec {
buf: Vec;
i: number;
s: number;
}

export interface ReadonlyVec extends
Iterable<number>,
ILength {
readonly [id: number]: number;
export interface IVector<T> extends
Vec,
ICopy<T>,
IEmpty<T>,
IEqualsDelta<T>,
StridedVec {
}

export interface MultiVecOp<VOP> {
Expand Down
20 changes: 2 additions & 18 deletions packages/vectors3/src/internal/avec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Vec } from "../api";
import { StridedVec, Vec } from "../api";

export abstract class AVec {
export abstract class AVec implements StridedVec {

buf: Vec;
i: number;
Expand All @@ -15,20 +15,4 @@ export abstract class AVec {
abstract get length(): number;

abstract [Symbol.iterator](): IterableIterator<number>;

get dim() {
return 1;
}

get offset() {
return this.i;
}

get shape() {
return [this.length];
}

get stride() {
return [this.s];
}
}

0 comments on commit 25b9789

Please sign in to comment.