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

52
LINES

< > BotCompany Repo | #1011348 // WebThoughtSpace

JavaX fragment (include)

sclass WebThoughtSpace extends OptionalConcept {
  S globalID;
  new Webs webs;
  new L<Web> openQuestions;

  transient Map<S, Web> websByID;
  transient MultiMap<S, WebNode> index;

  class Webs extends NotifyingList<Web> {
    *() { super(new L); }
    *(L<Web> l) { super(l); }
    
    public synchronized bool add(Web web) {
      synchronized(this) {
        if (!list.add(web)) false;
      }
      lock dbLock();
      if (index != null)
        ai_addWebToIndex(index, web);
      if (websByID != null)
        websByID.put(web.globalID, web);
      _change();
      true;
    }
    
    void change() {
      lock dbLock();
      index = null;
      websByID = null;
      _change();
    }
    
    public synchronized L<Web> subList(int i, int j) {
      ret new Webs(list.subList(i, j));
    }
  }

  *() {}
  *(Web... webs) {
    addAll(this.webs, webs);
  }
  
  void addWeb(Web web) { webs.add(web); }
  
  WebNode indexedNode(S query) { ret first(indexedNodes(query)); }
  L<WebNode> indexedNodes(S query) {
    lock dbLock();
    if (index == null)
      index = ai_indexWebs(webs);
    ret index.get(query);
  }
}

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: 451 / 1075
Version history: 15 change(s)
Referenced in: [show references]