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

25
LINES

< > BotCompany Repo | #1031068 // diffConceptShadows

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (15846L/102K).

static L<CreatedDeletedChanged<ConceptShadow>> diffConceptShadows(L<ConceptShadow> l1, L<ConceptShadow> l2) {
  new L<CreatedDeletedChanged<ConceptShadow>> diffs;
  int i1 = 0, i2 = 0;
  while (i1 < l(l1) && i2 < l(l2)) {
    ConceptShadow s1 = l1.get(i1), s2 = l2.get(i2);
    long id1 = s1.id(), id2 = s2.id();
    if (id1 < id2) {
      diffs.add(new CreatedDeletedChanged.Deleted(s1));
      ++i1;
    } else if (id1 > id2) {
      diffs.add(new CreatedDeletedChanged.Created(s2));
      ++i2;
    } else {
      if (!eq(s1, s2))
        diffs.add(new CreatedDeletedChanged.Changed(s1, s2));
      ++i1;
      ++i2;
    }
  }
  while (i1 < l(l1))
    diffs.add(new CreatedDeletedChanged.Deleted(l1.get(i1++)));
  while (i2 < l(l2))
    diffs.add(new CreatedDeletedChanged.Created(l2.get(i2++)));
  ret diffs;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031068
Snippet name: diffConceptShadows
Eternal ID of this version: #1031068/2
Text MD5: 13a8f3c1a93a86c2acbe0b7243028365
Transpilation MD5: 56538d6ede8d274ed3a67f984901b9c8
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-26 18:23:43
Source code size: 838 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 192 / 258
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1031075 - filterConceptShadows - only retain elements of first list which are in second list (by id)