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

18
LINES

< > BotCompany Repo | #1012606 // ai_smallerCategoryComparator - smallest categories first

JavaX fragment (include)

static TimedCache<Comparator<S>> ai_smallerCategoryComparator_cache = new TimedCache(10.0);

static Comparator<S> ai_smallerCategoryComparator() {
  ret ai_smallerCategoryComparator_cache.get(f ai_smallerCategoryComparator_uncached);
}

static Comparator<S> ai_smallerCategoryComparator_uncached() {
  final Set<Pair<S>> set = new HashSet(pairsToLower(ai_texts_unquoteBoth("is a smaller category than")));
  ret new Comparator<S>() {
    public int compare(S a, S b) {
      a = lower(a);
      b = lower(b);
      if (set.contains(pair(a, b))) ret -1;
      if (set.contains(pair(b, a))) ret 1;
      ret 0;
    }
  };
}

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: #1012606
Snippet name: ai_smallerCategoryComparator - smallest categories first
Eternal ID of this version: #1012606/5
Text MD5: 7d54816c7ef88422c6f4d2a801f646b0
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-07 17:00:23
Source code size: 638 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 354 / 405
Version history: 4 change(s)
Referenced in: [show references]