mqtt and socket added

This commit is contained in:
Miisa Ekholm
2022-10-21 11:17:48 +03:00
parent 52370df9ce
commit 9e3d953b9e
751 changed files with 185105 additions and 153 deletions

View File

@@ -0,0 +1,13 @@
import { ContainerIterator } from "../../ContainerBase/index";
export declare abstract class RandomIterator<T> extends ContainerIterator<T> {
protected node: number;
protected readonly size: () => number;
protected readonly getElementByPos: (pos: number) => T;
protected readonly setElementByPos: (pos: number, element: T) => void;
pre: () => this;
next: () => this;
constructor(index: number, size: () => number, getElementByPos: (pos: number) => T, setElementByPos: (pos: number, element: T) => void, iteratorType?: boolean);
get pointer(): T;
set pointer(newValue: T);
equals(obj: RandomIterator<T>): boolean;
}

View File

@@ -0,0 +1,77 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { checkWithinAccessParams } from "../../../utils/checkParams";
import { ContainerIterator } from "../../ContainerBase/index";
var RandomIterator = /** @class */ (function (_super) {
__extends(RandomIterator, _super);
function RandomIterator(index, size, getElementByPos, setElementByPos, iteratorType) {
var _this = _super.call(this, iteratorType) || this;
_this.node = index;
_this.size = size;
_this.getElementByPos = getElementByPos;
_this.setElementByPos = setElementByPos;
if (_this.iteratorType === ContainerIterator.NORMAL) {
_this.pre = function () {
if (this.node === 0) {
throw new RangeError('Deque iterator access denied!');
}
this.node -= 1;
return this;
};
_this.next = function () {
if (this.node === this.size()) {
throw new RangeError('Deque Iterator access denied!');
}
this.node += 1;
return this;
};
}
else {
_this.pre = function () {
if (this.node === this.size() - 1) {
throw new RangeError('Deque iterator access denied!');
}
this.node += 1;
return this;
};
_this.next = function () {
if (this.node === -1) {
throw new RangeError('Deque iterator access denied!');
}
this.node -= 1;
return this;
};
}
return _this;
}
Object.defineProperty(RandomIterator.prototype, "pointer", {
get: function () {
checkWithinAccessParams(this.node, 0, this.size() - 1);
return this.getElementByPos(this.node);
},
set: function (newValue) {
checkWithinAccessParams(this.node, 0, this.size() - 1);
this.setElementByPos(this.node, newValue);
},
enumerable: false,
configurable: true
});
RandomIterator.prototype.equals = function (obj) {
return this.node === obj.node;
};
return RandomIterator;
}(ContainerIterator));
export { RandomIterator };

View File

@@ -0,0 +1,44 @@
import { Container } from "../../ContainerBase/index";
declare abstract class SequentialContainer<T> extends Container<T> {
/**
* @description Push the element to the back.
* @param element The element you want to push.
*/
abstract pushBack(element: T): void;
/**
* @description Removes the last element.
*/
abstract popBack(): void;
/**
* @description Sets element by position.
* @param pos The position you want to change.
* @param element The element's value you want to update.
*/
abstract setElementByPos(pos: number, element: T): void;
/**
* @description Removes the elements of the specified value.
* @param value The value you want to remove.
*/
abstract eraseElementByValue(value: T): void;
/**
* @description Insert several elements after the specified position.
* @param pos The position you want to insert.
* @param element The element you want to insert.
* @param num The number of elements you want to insert (default 1).
*/
abstract insert(pos: number, element: T, num?: number): void;
/**
* @description Reverses the container.
*/
abstract reverse(): void;
/**
* @description Removes the duplication of elements in the container.
*/
abstract unique(): void;
/**
* @description Sort the container.
* @param cmp Comparison function.
*/
abstract sort(cmp?: (x: T, y: T) => number): void;
}
export default SequentialContainer;

View File

@@ -0,0 +1,24 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { Container } from "../../ContainerBase/index";
var SequentialContainer = /** @class */ (function (_super) {
__extends(SequentialContainer, _super);
function SequentialContainer() {
return _super !== null && _super.apply(this, arguments) || this;
}
return SequentialContainer;
}(Container));
export default SequentialContainer;