Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

46
LINES

< > BotCompany Repo | #1008190 // ThoughtSpace

JavaX fragment (include)

1  
sclass ThoughtSpace {
2  
  S globalID;
3  
  new LinkedHashMap<S, LispStatement> statements;
4  
  new HashMap<Lisp, LispStatement> statementsIndex;
5  
  new LinkedHashMap<S, SimpleConcept> concepts;
6  
  long changes;
7  
  
8  
  *() {}
9  
  *(S *globalID) {}
10  
  
11  
  void addStatements(L<Lisp> l) { for (Lisp x : l) addStatement(x); }
12  
  void addLispStatements(Collection<LispStatement> l) {
13  
    for (LispStatement x : l) addStatement(x);
14  
  }
15  
  
16  
  void addStatement(Lisp l) {
17  
    if (!containsStatement(l)) addStatement(new LispStatement(l));
18  
  }
19  
  
20  
  void addStatement(LispStatement s) {
21  
    statements.put(s.globalID, s);
22  
    statementsIndex.put(s.term, s);
23  
    ++changes;
24  
  }
25  
  
26  
  void removeStatement(S statementID) {
27  
    removeStatement(statements.get(statementID));
28  
  }
29  
  
30  
  void removeStatement(LispStatement s) {
31  
    if (s != null) removeStatement(s.term);
32  
  }
33  
  
34  
  void removeStatement(Lisp l) {
35  
    LispStatement s = statementsIndex.get(l);
36  
    if (s != null) {
37  
      statements.remove(s.globalID);
38  
      statementsIndex.remove(l);
39  
      ++changes;
40  
    }
41  
  }
42  
  
43  
  bool containsStatement(Lisp l) {
44  
    ret statementsIndex.containsKey(l);
45  
  }
46  
}

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: #1008190
Snippet name: ThoughtSpace
Eternal ID of this version: #1008190/13
Text MD5: d7c1ff265dd9cb51c1c84c576c85799e
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-07 00:36:04
Source code size: 1168 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 560 / 1276
Version history: 12 change(s)
Referenced in: [show references]