|
@@ -13,10 +13,10 @@ class LocationHolder {
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
- * @param {*} value the value to be allocated
|
|
|
|
- * @returns {Number} - the address id
|
|
|
|
|
|
+ * @param {never} value the value to be allocated
|
|
|
|
+ * @returns {number} - the address id
|
|
*/
|
|
*/
|
|
- allocate (value:any) : number {
|
|
|
|
|
|
+ allocate (value: unknown): number {
|
|
const id = this.address_id;
|
|
const id = this.address_id;
|
|
// console.log("Allocation address "+ id);
|
|
// console.log("Allocation address "+ id);
|
|
const address = new Address(id, value);
|
|
const address = new Address(id, value);
|
|
@@ -27,9 +27,9 @@ class LocationHolder {
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
- * @param {Number} id
|
|
|
|
|
|
+ * @param {number} id
|
|
*/
|
|
*/
|
|
- deallocate (id: number) : boolean {
|
|
|
|
|
|
+ deallocate (id: number): boolean {
|
|
const index = this.findIndex(id);
|
|
const index = this.findIndex(id);
|
|
// console.log("Deallocation address "+ id);
|
|
// console.log("Deallocation address "+ id);
|
|
if(index !== -1) {
|
|
if(index !== -1) {
|
|
@@ -41,7 +41,7 @@ class LocationHolder {
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
- * @param {Number} id
|
|
|
|
|
|
+ * @param {number} id
|
|
* @returns {Address} the address identified by id
|
|
* @returns {Address} the address identified by id
|
|
*/
|
|
*/
|
|
find (id: number): Address | undefined {
|
|
find (id: number): Address | undefined {
|
|
@@ -68,10 +68,10 @@ class LocationHolder {
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
- * @param {Number} id address id
|
|
|
|
- * @returns {Number} the index of the address identified by id
|
|
|
|
|
|
+ * @param {number} id address id
|
|
|
|
+ * @returns {number} the index of the address identified by id
|
|
*/
|
|
*/
|
|
- findIndex (id: number) : number {
|
|
|
|
|
|
+ findIndex (id: number): number {
|
|
let beg = 0
|
|
let beg = 0
|
|
let end = this.data.length;
|
|
let end = this.data.length;
|
|
while (beg < end) {
|
|
while (beg < end) {
|
|
@@ -88,7 +88,7 @@ class LocationHolder {
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- updateAddress (id: number, value: any): void {
|
|
|
|
|
|
+ updateAddress (id: number, value: unknown): void {
|
|
const index = this.findIndex(id);
|
|
const index = this.findIndex(id);
|
|
if(index === -1) {
|
|
if(index === -1) {
|
|
throw new Error("Invalid address..." + id);
|
|
throw new Error("Invalid address..." + id);
|
|
@@ -96,7 +96,7 @@ class LocationHolder {
|
|
this.data[index].value = value;
|
|
this.data[index].value = value;
|
|
}
|
|
}
|
|
|
|
|
|
- clear () {
|
|
|
|
|
|
+ clear (): void {
|
|
for (let i = 0; i < this.data.length; i += 1) {
|
|
for (let i = 0; i < this.data.length; i += 1) {
|
|
delete this.data[i];
|
|
delete this.data[i];
|
|
}
|
|
}
|