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

15
LINES

< > BotCompany Repo | #1021789 // swapConceptIDs - actually change the concepts' IDs

JavaX fragment (include)

// slightly experimental - also uses allChanged() which might not be
// so good with future logging
svoid swapConceptIDs(Concept a, Concept b) {
  Concepts concepts = a._concepts;
  if (concepts != b._concepts) fail("Concepts belong to different set");
  long id1 = a.id, id2 = b.id;
  if (concepts == null) { a.id = id2; b.id = id1; ret; }
  lock concepts.lock;
  a.id = id2;
  b.id = id1;
  concepts.concepts.put(id2, a);
  concepts.concepts.put(id1, b);
  a.change();
  b.change();
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021789
Snippet name: swapConceptIDs - actually change the concepts' IDs
Eternal ID of this version: #1021789/6
Text MD5: f0da7ed02aa0d7833bd33cb8f6eaea55
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-07-01 16:05:31
Source code size: 500 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 238 / 271
Version history: 5 change(s)
Referenced in: [show references]