Esempio n. 1
0
      @Override
      public int compare(FunctionDescProto o1, FunctionDescProto o2) {
        List<DataType> types1 = o1.getSignature().getParameterTypesList();
        List<DataType> types2 = o2.getSignature().getParameterTypesList();

        int minLen = Math.min(types1.size(), types2.size());

        for (int i = 0; i < minLen; i++) {
          int cmpVal = types1.get(i).getType().getNumber() - types2.get(i).getType().getNumber();

          if (cmpVal != 0) {
            return cmpVal;
          }
        }

        return types1.size() - types2.size();
      }
Esempio n. 2
0
 /**
  * Find the nearest matched function
  *
  * @param candidates Candidate Functions
  * @return
  */
 private FunctionDescProto findNearestMatchedFunction(List<FunctionDescProto> candidates) {
   Collections.sort(candidates, new NearestParamsComparator());
   return candidates.get(0);
 }