Created
March 22, 2025 11:11
-
-
Save trikitrok/45b4ef2d4a634b36c65519a51bb408e0 to your computer and use it in GitHub Desktop.
Used to illustrate finding test points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class InMemoryDirectory { | |
private readonly elements: Element[]; | |
constructor() { | |
this.elements = []; | |
} | |
public addElement(newElement: Element): void { | |
this.elements.push(newElement); | |
} | |
public generateIndex(): void { | |
const index = new Element("index"); | |
for (const element of this.elements) { | |
index.addText(element.getName() + "\n"); | |
} | |
this.addElement(index); | |
} | |
public getElementCount(): number { | |
return this.elements.length; | |
} | |
public getElement(name: string): Element | null { | |
for (const element of this.elements) { | |
if (element.getName() === name) { | |
return element; | |
} | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment