feat(d.ts)
This commit is contained in:
43
types/List.d.ts
vendored
Normal file
43
types/List.d.ts
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
import { SequenceContainer } from "./containers/Sequence";
|
||||
import { BidirectionalIterator } from "./iterators/Bidirectional";
|
||||
import { Item } from "./iterators/Forward";
|
||||
|
||||
export class List<T> extends SequenceContainer<T> {
|
||||
/**
|
||||
* empty list
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* list with single element
|
||||
* @param value which will be inserted
|
||||
*/
|
||||
constructor(value: T);
|
||||
/**
|
||||
* list with n similar elements
|
||||
* @param value which will be inserted
|
||||
* @param n count of how many values will be inserted
|
||||
*/
|
||||
constructor(value: T, n: number);
|
||||
/**
|
||||
* copies range of another list
|
||||
* @param begin of another SequenceContainer<T>
|
||||
* @param end of another SequenceContainer<T>
|
||||
*/
|
||||
constructor(begin: ListIterator<T>, end: ListIterator<T>);
|
||||
|
||||
/**
|
||||
* creates list from array, string and other iterable object
|
||||
*/
|
||||
static from<T>(obj: Iterable<T>): List<T>;
|
||||
}
|
||||
|
||||
export class ListItem<T> extends Item<T> {
|
||||
get next(): ListItem<T>;
|
||||
get prev(): ListItem<T>;
|
||||
|
||||
private constructor();
|
||||
}
|
||||
|
||||
export class ListIterator<T> extends BidirectionalIterator<T> {
|
||||
private constructor();
|
||||
}
|
||||
90
types/containers/Sequence.d.ts
vendored
Normal file
90
types/containers/Sequence.d.ts
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
import { BidirectionalIterator } from "../iterators/Bidirectional";
|
||||
|
||||
export class SequenceContainer<T> {
|
||||
move(rhs: SequenceContainer<T>): this;
|
||||
size(): number;
|
||||
begin(): BidirectionalIterator<T>;
|
||||
end(): BidirectionalIterator<T>;
|
||||
|
||||
clone(): this;
|
||||
copy(rhs: SequenceContainer<T>): this;
|
||||
empty(): boolean;
|
||||
/**
|
||||
* @returns direct access to front item's value
|
||||
*/
|
||||
get front(): T;
|
||||
set front(value: T);
|
||||
/**
|
||||
* @returns direct access to back item's value
|
||||
*/
|
||||
get back(): T;
|
||||
set back(value: T);
|
||||
/**
|
||||
* inserts [begin, end) at dest
|
||||
* @param dest where to insert
|
||||
* @param begin of another SequenceContainer<T>
|
||||
* @param end of another SequenceContainer<T>
|
||||
* @returns iterator right after end iterator
|
||||
*/
|
||||
insert(dest: BidirectionalIterator<T>, begin: BidirectionalIterator<T>, end: BidirectionalIterator<T>): BidirectionalIterator<T>;
|
||||
/**
|
||||
* inserts [begin, end) at dest
|
||||
* @param dest where to insert
|
||||
* @param value which will be inserted
|
||||
* @param n count of how many values will be inserted
|
||||
* @returns iterator right after last inserted value
|
||||
*/
|
||||
insert(dest: BidirectionalIterator<T>, value: T, n: number): BidirectionalIterator<T>;
|
||||
/**
|
||||
* inserts [begin, end) at dest
|
||||
* @param dest where to insert
|
||||
* @param value which will be inserted
|
||||
* @returns iterator right after inserted value
|
||||
*/
|
||||
insert(dest: BidirectionalIterator<T>, value: T): BidirectionalIterator<T>;
|
||||
/**
|
||||
* same as list.clear(); list.insert(list.begin(), ...)
|
||||
* @param begin of another SequenceContainer<T>
|
||||
* @param end of another SequenceContainer<T>
|
||||
* @returns end iterator
|
||||
*/
|
||||
assign(begin: BidirectionalIterator<T>, end: BidirectionalIterator<T>): BidirectionalIterator<T>;
|
||||
/**
|
||||
* same as list.clear(); list.insert(list.begin(), ...)
|
||||
* @param value which will be inserted
|
||||
* @param n count of how many values will be inserted
|
||||
* @returns iterator right after last inserted value
|
||||
*/
|
||||
assign(value: T, n: number): BidirectionalIterator<T>;
|
||||
/**
|
||||
* same as list.clear(); list.insert(list.begin(), ...)
|
||||
* @param value which will be inserted
|
||||
* @returns iterator right after inserted value
|
||||
*/
|
||||
assign(value: T): BidirectionalIterator<T>;
|
||||
/**
|
||||
* erases [begin, end)
|
||||
* @param begin of erased range
|
||||
* @param end of erased range
|
||||
* @returns iterator right after erased range
|
||||
*/
|
||||
erase(begin: BidirectionalIterator<T>, end: BidirectionalIterator<T>): BidirectionalIterator<T>;
|
||||
/**
|
||||
* erases single item
|
||||
* @param begin which points to erased item
|
||||
* @returns iterator right after erased value
|
||||
*/
|
||||
erase(begin: BidirectionalIterator<T>): BidirectionalIterator<T>;
|
||||
/**
|
||||
* same as list.erase(list.begin(), list.end())
|
||||
* @returns end iterator
|
||||
*/
|
||||
clear(): BidirectionalIterator<T>;
|
||||
pushFront(value: T): void;
|
||||
pushBack(value: T): void;
|
||||
popFront(): void;
|
||||
popBack(): void;
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
toJSON(): string;
|
||||
toString(): string;
|
||||
}
|
||||
5
types/index.d.ts
vendored
Normal file
5
types/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import type { ForwardIterator } from "./iterators/Forward"
|
||||
import type { BidirectionalIterator } from "./iterators/Bidirectional"
|
||||
import type { SequenceContainer } from "./containers/Sequence"
|
||||
import type { List, ListIterator, ListItem } from "./List"
|
||||
export type { ForwardIterator, BidirectionalIterator, SequenceContainer, List, ListIterator, ListItem }
|
||||
9
types/iterators/Bidirectional.d.ts
vendored
Normal file
9
types/iterators/Bidirectional.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import { ForwardIterator } from "./Forward";
|
||||
|
||||
export class BidirectionalIterator<T> extends ForwardIterator<T> {
|
||||
/**
|
||||
* decrements iterator, it doesn't make copy
|
||||
* @returns {this}
|
||||
*/
|
||||
dec(): this;
|
||||
}
|
||||
24
types/iterators/Forward.d.ts
vendored
Normal file
24
types/iterators/Forward.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
export class Item<T> {
|
||||
value: T
|
||||
}
|
||||
|
||||
export class ForwardIterator<T> {
|
||||
clone(): ForwardIterator<T>;
|
||||
copy(rhs: ForwardIterator<T>): this;
|
||||
deref(): Item<T>;
|
||||
eq(rhs: ForwardIterator<T>): boolean;
|
||||
/**
|
||||
* increments iterator, it doesn't make copy
|
||||
* @returns {this}
|
||||
*/
|
||||
inc(): this;
|
||||
|
||||
/**
|
||||
* move-semantics, here it just copies rhs into this
|
||||
* @returns {this}
|
||||
*/
|
||||
move(rhs: ForwardIterator<T>): this;
|
||||
get value(): T;
|
||||
set value(value: T);
|
||||
neq(rhs: ForwardIterator<T>): boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user