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

29
LINES

< > BotCompany Repo | #1014762 // ciClusters_add - add relations to a cluster list

JavaX fragment (include)

static Collection<S> ciClusters_add(Clusters<S> clusters, L<S> l) {
  for (int i = 0; i < l(l)-1; i++)
    ciClusters_add(clusters, l.get(i), l.get(i+1));
  ret clusters.get(first(l));
}

static void ciClusters_add(Clusters<S> clusters, S a, S b) {
  if (eqic(a, b)) {
    Collection<S> cluster = clusters.get(a);
    if (cluster == null)
      clusters.put(a, litciset(a));
    ret;
  }
  
  Collection<S> clusterA = clusters.get(a);
  Collection<S> clusterB = clusters.get(b);
  if (clusterA == null && clusterB == null) {
    L<S> cluster = ll(a, b);
    clusters.put(a, cluster);
    clusters.put(b, cluster);
  } else if (clusterA == null) {
    clusterB.add(a);
    clusters.put(a, clusterB);
  } else if (clusterB == null) {
    clusterA.add(b);
    clusters.put(b, clusterA);
  } else if (clusterA != clusterB)
    treeSetClusters_merge(clusters, clusterA, clusterB);
}

Author comment

Began life as a copy of #1010458

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: #1014762
Snippet name: ciClusters_add - add relations to a cluster list
Eternal ID of this version: #1014762/3
Text MD5: d474a0b9ac986faafef7367947fe704a
Author: stefan
Category: javax / math
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-01 20:25:07
Source code size: 905 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 431 / 442
Version history: 2 change(s)
Referenced in: [show references]