static class AIEngine {
new L<S> sentences;
new Set<S> sentenceSet;
new Map<S, O> objects;
new IdentityHashMap<O, S> objectToID;
long objectIDCounter;
S addObject(O o) {
S id = objectToID.get(o);
if (id == null) {
id = "o" + ++objectIDCounter;
objects.put(id, o);
objectToID.put(o, id);
}
return id;
}
S remember(S sentence) {
if (!sentenceSet.contains(sentence)) {
sentenceSet.add(sentence);
sentences.add(sentence);
return addObject(sentence);
}
return null;
}
void show() {
for (S s : sentences)
print(" " + s);
}
<A> A findObjectOfType(Class<A> c) {
for (O o : objects.values())
if (o.getClass() == c)
return (A) o;
return null;
}
}download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1001107 |
| Snippet name: | class AIEngine |
| Eternal ID of this version: | #1001107/1 |
| Text MD5: | 11a739dfe06c6e0366a7c9ddc68799f1 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-09-21 17:51:36 |
| Source code size: | 808 bytes / 38 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 862 / 1090 |
| Referenced in: | [show references] |