import { BiMap } from "@/util/bi-map"; export class NamespaceTable { OPC_UA = "http://opcfoundation.org/UA/"; nsMap = new BiMap(); constructor() { this.nsMap.set(0, this.OPC_UA) } addUri(uri: string):number|undefined { if(this.nsMap.hasValue(uri)) { return this.nsMap.getFromValue(uri); } else { let index=1; while (this.nsMap.hasKey(index)) { index = index + 1; } this.nsMap.set(index, uri); return index; } } putUri(uri: string, index: number): void { this.nsMap.set(index, uri); } getUri(index: number): string|undefined { return this.nsMap.get(index); } getIndex(uri: string) : number|undefined { return this.nsMap.getFromValue(uri); } }