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

52
LINES

< > BotCompany Repo | #1011348 // WebThoughtSpace

JavaX fragment (include)

1  
sclass WebThoughtSpace extends OptionalConcept {
2  
  S globalID;
3  
  new Webs webs;
4  
  new L<Web> openQuestions;
5  
6  
  transient Map<S, Web> websByID;
7  
  transient MultiMap<S, WebNode> index;
8  
9  
  class Webs extends NotifyingList<Web> {
10  
    *() { super(new L); }
11  
    *(L<Web> l) { super(l); }
12  
    
13  
    public synchronized bool add(Web web) {
14  
      synchronized(this) {
15  
        if (!list.add(web)) false;
16  
      }
17  
      lock dbLock();
18  
      if (index != null)
19  
        ai_addWebToIndex(index, web);
20  
      if (websByID != null)
21  
        websByID.put(web.globalID, web);
22  
      _change();
23  
      true;
24  
    }
25  
    
26  
    void change() {
27  
      lock dbLock();
28  
      index = null;
29  
      websByID = null;
30  
      _change();
31  
    }
32  
    
33  
    public synchronized L<Web> subList(int i, int j) {
34  
      ret new Webs(list.subList(i, j));
35  
    }
36  
  }
37  
38  
  *() {}
39  
  *(Web... webs) {
40  
    addAll(this.webs, webs);
41  
  }
42  
  
43  
  void addWeb(Web web) { webs.add(web); }
44  
  
45  
  WebNode indexedNode(S query) { ret first(indexedNodes(query)); }
46  
  L<WebNode> indexedNodes(S query) {
47  
    lock dbLock();
48  
    if (index == null)
49  
      index = ai_indexWebs(webs);
50  
    ret index.get(query);
51  
  }
52  
}

Author comment

Began life as a copy of #1011346

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: #1011348
Snippet name: WebThoughtSpace
Eternal ID of this version: #1011348/16
Text MD5: 173fe7082d6a84407812b58d8799c866
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-26 03:25:39
Source code size: 1183 bytes / 52 lines
Pitched / IR pitched: No / No
Views / Downloads: 389 / 1005
Version history: 15 change(s)
Referenced in: [show references]