Compares two suggestion objects
@param suggestion
@param instance other Suggestions instance
334626
function belongsToArea(suggestion, instance){
    var parentSuggestion = instance.selection,
        result = parentSuggestion && parentSuggestion.data && instance.bounds;

    if (result) {
        collection_util.each(instance.bounds.all, function (bound, i) {
            return (result = parentSuggestion.data[bound] === suggestion.data[bound]);
        });
    }
    return result;
}
467353
@SuppressWarnings("unchecked")
    public Recommendation evaluate(M milestone, DataBinder binder, Reifier dict, Persistence persist) {
        Evaluation evaluation = _evaluations[milestone.ordinal()];
        return evaluation != null ? evaluation.evaluate((Class<M>)milestone.getClass(), milestone.toString(), binder, dict, persist) : Recommendation.CONTINUE;
    }
1005667
@Override
	public void trainOnInstanceImpl(Instance instance) {
		/**
		 * AMRules Algorithm
		 * 
		 //For each rule in the rule set
			//If rule covers the instance
				//if the instance is not an anomaly	
					//Update Change Detection Tests
				    	//Compute prediction error
				    	//Call PHTest
						//If change is detected then
							//Remove rule
						//Else
							//Update sufficient statistics of rule
							//If number of examples in rule  > Nmin
								//Expand rule
						//If ordered set then
							//break
			//If none of the rule covers the instance
				//Update sufficient statistics of default rule
				//If number of examples in default rule is multiple of Nmin
					//Expand default rule and add it to the set of rules
					//Reset the default rule
		 */
		numInstances+=instance.weight();
		debug("Train",3);
		debug("Nº instance "+numInstances + " - " + instance.toString(),3);
		boolean rulesCoveringInstance = false;
		Iterator<Rule> ruleIterator= this.ruleSet.iterator();
		while (ruleIterator.hasNext()) { 
			Rule rule = ruleIterator.next();
			if (rule.isCovering(instance) == true) {
				rulesCoveringInstance = true;
				if (isAnomaly(instance, rule) == false) {
					//Update Change Detection Tests
					double error = rule.computeError(instance); //Use adaptive mode error
					boolean changeDetected = rule.getLearningNode().updateChangeDetection(error);
					if (changeDetected == true) {
						debug("I) Drift Detected. Exa. : " +  this.numInstances + " (" + rule.getInstancesSeen() +") Remove Rule: " +rule.getRuleNumberID(),1);

						ruleIterator.remove();
						this.numChangesDetected+=instance.weight();   
					} else {
						rule.updateStatistics(instance);
						if (rule.getInstancesSeen()  % this.gracePeriodOption.getValue() == 0.0) {
							if (rule.tryToExpand(this.splitConfidenceOption.getValue(), this.tieThresholdOption.getValue()) ) 
							{
								rule.split();
								debug("Rule Expanded:",2);
								debug(rule.printRule(),2);
							}	
						}
					}
				}
				else {
					debug("Anomaly Detected: " + this.numInstances + " Rule: " +rule.getRuleNumberID() ,1);
					this.numAnomaliesDetected+=instance.weight();
				}
				if (!this.unorderedRulesOption.isSet()) 
					break;
			}
		}	

		if (rulesCoveringInstance == false){ 
			defaultRule.updateStatistics(instance);
			if (defaultRule.getInstancesSeen() % this.gracePeriodOption.getValue() == 0.0) {
				debug("Nr. examples "+defaultRule.getInstancesSeen(), 4);

				if (defaultRule.tryToExpand(this.splitConfidenceOption.getValue(), this.tieThresholdOption.getValue()) == true) {
					Rule newDefaultRule=newRule(defaultRule.getRuleNumberID(),defaultRule.getLearningNode(),defaultRule.getLearningNode().getStatisticsOtherBranchSplit()); //other branch
					defaultRule.split();
					defaultRule.setRuleNumberID(++ruleNumberID);
					this.ruleSet.add(this.defaultRule);

					debug("Default rule expanded! New Rule:",2);
					debug(defaultRule.printRule(),2);
					debug("New default rule:", 3);	
					debug(newDefaultRule.printRule(),3);
					defaultRule=newDefaultRule;

				}
			}
		}
	}
19085
private static int compare(Treenode item1, Treenode item2) {
        String label1 = item1.getLabel();
        String label2 = item2.getLabel();
        return label1 == label2 ? 0 : label1 == null ? -1 : label2 == null ? -1 : label1.compareToIgnoreCase(label2);
    }
754346
function (suggestionNode, className) {
            var suggestionNodeClassList = new aria.utils.ClassList(suggestionNode);
            suggestionNodeClassList.add(className);
            suggestionNodeClassList.$dispose();
        }
953600
function (item) {
            // Check if it already exists in the suggestions list.  Duplicates aren't allowed.
            var exists = false;
            for(var j = 0; j < suggestions.length; j++){
              if(suggestions[j].attr('name').toLowerCase() === item.name.toLowerCase()){
                exists=true;
                break;
              }
            }
            // If it didn't exist, add it to the list of suggestions and the searchTerms.
            if(!exists){
              suggestions.push(item);
            }

            // We are using searchTerms's setter to execute the filter, so have to set the property (not just update):
            var searchTerms = self.viewModel.attr('searchTerms').attr().concat(item.name);
            self.viewModel.attr('searchTerms', searchTerms);
          }
1331879
public List<SuggestItem> lookup(String input, Verbosity verbosity, int maxEditDistance) {
    //verbosity=Top: the suggestion with the highest term frequency of the suggestions of smallest edit distance found
    //verbosity=Closest: all suggestions of smallest edit distance found, the suggestions are ordered by term frequency
    //verbosity=All: all suggestions <= maxEditDistance, the suggestions are ordered by edit distance, then by term frequency (slower, no early termination)

    // maxEditDistance used in lookup can't be bigger than the maxDictionaryEditDistance
    // used to construct the underlying dictionary structure.
    if (maxEditDistance > maxDictionaryEditDistance) {
      throw new IllegalArgumentException("Dist to big: " + maxEditDistance);
    }

    List<SuggestItem> suggestions = new ArrayList<>();
    int inputLen = input.length();

    // early exit - word is too big to possibly match any words
    if (inputLen - maxEditDistance > maxLength) {
      return suggestions;
    }

    // deletes we've considered already
    HashSet<String> consideredDeletes = new HashSet<>();
    // suggestions we've considered already
    HashSet<String> consideredSuggestions = new HashSet<>();
    long suggestionCount;

    // quick look for exact match
    if (words.containsKey(input)) {
      suggestionCount = words.get(input);
      suggestions.add(new SuggestItem(input, 0, suggestionCount));
      // early exit - return exact match, unless caller wants all matches
      if (verbosity != Verbosity.All) {
        return suggestions;
      }
    }
    consideredSuggestions.add(input); // input considered in above.

    int maxEditDistance2 = maxEditDistance;
    int candidatePointer = 0;
    List<String> candidates = new ArrayList<>();

    //add original prefix
    int inputPrefixLen = inputLen;
    if (inputPrefixLen > prefixLength) {
      inputPrefixLen = prefixLength;
      candidates.add(input.substring(0, inputPrefixLen));
    } else {
      candidates.add(input);
    }

    EditDistance distanceComparer = new EditDistance(input, this.distanceAlgorithm);
    while (candidatePointer < candidates.size()) {
      String candidate = candidates.get(candidatePointer++);
      int candidateLen = candidate.length();
      int lengthDiff = inputPrefixLen - candidateLen;

      //early termination if distance higher than suggestion distance
      if (lengthDiff > maxEditDistance2) {
        // skip to next candidate if Verbosity.All, look no further if Verbosity.Top or Closest
        // (candidates are ordered by delete distance, so none are closer than current)
        if (verbosity == Verbosity.All) {
          continue;
        }
        break;
      }

      //read candidate entry from dictionary
      if (deletes.containsKey(getStringHash(candidate))) {
        String[] dictSuggestions = deletes.get(getStringHash(candidate));
        //iterate through suggestions (to other correct dictionary items) of delete item and add them to suggestion list
        for (String suggestion : dictSuggestions) {
          if (suggestion.equals(input)) {
            continue;
          }
          int suggestionLen = suggestion.length();

          if ((Math.abs(suggestionLen - inputLen) > maxEditDistance2) // input/suggestion diff > allowed/current best distance
            || (suggestionLen < candidateLen) // sugg must be for a different delete String, in same bin only because of hash collision
            || (suggestionLen == candidateLen && !suggestion.equals(candidate))) // if sugg len = delete len, then it either equals delete or is in same bin only because of hash collision
          {
            continue;
          }

          int suggPrefixLen = Math.min(suggestionLen, prefixLength);
          if (suggPrefixLen > inputPrefixLen && (suggPrefixLen - candidateLen) > maxEditDistance2) {
            continue;
          }

          //True Damerau-Levenshtein Edit Distance: adjust distance, if both distances > 0
          //We allow simultaneous edits (deletes) of maxEditDistance on on both the dictionary and the input term.
          //For replaces and adjacent transposes the resulting edit distance stays <= maxEditDistance.
          //For inserts and deletes the resulting edit distance might exceed maxEditDistance.
          //To prevent suggestions of a higher edit distance, we need to calculate the resulting edit distance, if there are simultaneous edits on both sides.
          //Example: (bank==bnak and bank==bink, but bank!=kanb and bank!=xban and bank!=baxn for maxEditDistance=1)
          //Two deletes on each side of a pair makes them all equal, but the first two pairs have edit distance=1, the others edit distance=2.
          int distance;
          int min = 0;
          if (candidateLen == 0) {
            //suggestions which have no common chars with input (inputLen<=maxEditDistance && suggestionLen<=maxEditDistance)
            distance = Math.max(inputLen, suggestionLen);
            if (distance > maxEditDistance2 || !consideredSuggestions.add(suggestion)) {
              continue;
            }
          } else if (suggestionLen == 1) {
            if (input.indexOf(suggestion.charAt(0)) < 0) {
              distance = inputLen;
            } else {
              distance = inputLen - 1;
            }
            if (distance > maxEditDistance2 || !consideredSuggestions.add(suggestion)) {
              continue;
            }
          } else
            //number of edits in prefix == maxeditdistance  && no identic suffix
            //, then editdistance > maxEditDistance and no need for Levenshtein calculation
            //      (inputLen >= prefixLength) && (suggestionLen >= prefixLength)
            if ((prefixLength - maxEditDistance == candidateLen)
              && (((min = Math.min(inputLen, suggestionLen) - prefixLength) > 1)
              && !(input.substring(inputLen + 1 - min).equals(suggestion.substring(suggestionLen + 1 - min))))
              || ((min > 0) && (input.charAt(inputLen - min) != suggestion.charAt(suggestionLen - min))
              && ((input.charAt(inputLen - min - 1) != suggestion.charAt(suggestionLen - min))
              || (input.charAt(inputLen - min) != suggestion.charAt(suggestionLen - min - 1))))) {
              continue;
            } else {
              // deleteInSuggestionPrefix is somewhat expensive, and only pays off when verbosity is Top or Closest.
              if ((verbosity != Verbosity.All && !deleteInSuggestionPrefix(candidate, candidateLen, suggestion, suggestionLen))
                || !consideredSuggestions.add(suggestion)) {
                continue;
              }
              distance = distanceComparer.compare(suggestion, maxEditDistance2);
              if (distance < 0) {
                continue;
              }
            }

          //save some time
          //do not process higher distances than those already found, if verbosity<All (note: maxEditDistance2 will always equal maxEditDistance when Verbosity.All)
          if (distance <= maxEditDistance2) {
            suggestionCount = words.get(suggestion);
            SuggestItem si = new SuggestItem(suggestion, distance, suggestionCount);
            if (suggestions.size() > 0) {
              switch (verbosity) {
                case Closest:
                  //we will calculate DamLev distance only to the smallest found distance so far
                  if (distance < maxEditDistance2) {
                    suggestions.clear();
                  }
                  break;
                case Top:
                  if (distance < maxEditDistance2 || suggestionCount > suggestions.get(0).count) {
                    maxEditDistance2 = distance;
                    suggestions.set(0, si);
                  }
                  continue;
              }
            }
            if (verbosity != Verbosity.All) {
              maxEditDistance2 = distance;
            }
            suggestions.add(si);
          }
        }
      }

      //add edits
      //derive edits (deletes) from candidate (input) and add them to candidates list
      //this is a recursive process until the maximum edit distance has been reached
      if ((lengthDiff < maxEditDistance) && (candidateLen <= prefixLength)) {
        //save some time
        //do not create edits with edit distance smaller than suggestions already found
        if (verbosity != Verbosity.All && lengthDiff >= maxEditDistance2) {
          continue;
        }

        for (int i = 0; i < candidateLen; i++) {
          StringBuilder sb = new StringBuilder(candidate);
          sb.deleteCharAt(i);
          String delete = sb.toString();

          if (consideredDeletes.add(delete)) {
            candidates.add(delete);
          }
        }
      }
    }

    //sort by ascending edit distance, then by descending word frequency
    if (suggestions.size() > 1) {
      Collections.sort(suggestions);
    }
    return suggestions;
  }
1123495
public void updateInstance(
      Instance my_instance,
      final String my_client_project,
      final String my_instance_id,
      final String my_display_name) {
    // [START instance_admin_client_update_instance]
    Instance instance = my_instance;
    final String clientProject = my_client_project;
    final String instanceId = my_instance_id;

    final String newDisplayName = my_display_name;

    InstanceInfo toUpdate =
        InstanceInfo.newBuilder(InstanceId.of(clientProject, instanceId))
            .setDisplayName(newDisplayName)
            .setNodeCount(instance.getNodeCount() + 1)
            .build();
    // Only update display name
    OperationFuture<Instance, UpdateInstanceMetadata> op =
        instanceAdminClient.updateInstance(toUpdate, InstanceInfo.InstanceField.DISPLAY_NAME);
    try {
      op.get();
    } catch (ExecutionException e) {
      throw (SpannerException) e.getCause();
    } catch (InterruptedException e) {
      throw SpannerExceptionFactory.propagateInterrupt(e);
    }
    // [END instance_admin_client_update_instance]
  }
621112
public int compare(Object o1, Object o2) {
		List list1 = (List) o1;
		List list2 = (List) o2;

		for (int i = 0; i < list1.size(); i++) {
			if (list2.size() > i) {
				Comparable component1 = (Comparable) list1.get(i);
				Comparable component2 = (Comparable) list2.get(i);
				int componentsCompared = component1.compareTo(component2);
				if (componentsCompared != 0) {
					return componentsCompared;
				}
			}
			else {
				// First instance has more components, so that instance is
				// greater.
				return 1;
			}
		}

		// All components so far are equal - if the other instance has
		// more components it is greater otherwise they are equal.
		if (list2.size() > list1.size()) {
			return -1;
		}
		else {
			return 0;
		}
	}
323092
public void setSuggestions(final List<String> suggestions) {
		SuggestionsModel model = getOrCreateComponentModel();
		model.setSuggestions(suggestions);
	}
335641
function (suggestionsList, suggestion) {
                for (var i = 0, l = suggestionsList.length; i < l; i++) {
                    if (suggestion.label == suggestionsList[i].label) {
                        return i;
                    }
                }
                return -1;
            }
1169002
function (suggestions, textEntry) {
                var matchValueIndex = -1, suggestion;
                for (var index = 0, len = suggestions.length, label, ariaLabel; index < len; index += 1) {
                    suggestion = suggestions[index];
                    // if it's the first exact match, store it
                    if (matchValueIndex == -1) {
                        if (suggestion.exactMatch) {
                            matchValueIndex = index;
                        }
                    }
                    label = this._getLabelFromSuggestion(suggestion);
                    ariaLabel = this.waiSuggestionAriaLabelGetter ? this.waiSuggestionAriaLabelGetter({
                        value: suggestion,
                        index: index,
                        total: len
                    }) : null;
                    var tmp = {
                        entry : textEntry,
                        label : label,
                        ariaLabel : ariaLabel,
                        value : suggestion
                    };
                    suggestions[index] = tmp;
                }
                return this.preselect === "none" ? -1 : matchValueIndex;
            }
919598
public int compare(final SnomedConcept o1, final SnomedConcept o2) {
        if (o1 == o2) return 0;
        if (o1 != null) {
            if (o2 == null) return 1;
            else return o1.candidatePreferred.compareTo(o2.candidatePreferred);
        }
        return -1;
    }
8059
private int compare(Object k1, Object k2) {
        return (mComparator==null ? ((Comparable)k1).compareTo(k2)
                : mComparator.compare(k1, k2));
    }
171424
public int compare(Object objA, Object objB)
    {
        if (!(objA instanceof DefBase) || !(objB instanceof DefBase))
        {
            return 0;
        }
        else
        {
            return ((DefBase)objA).getName().compareTo(((DefBase)objB).getName());
        }
    }
898673
public static boolean objectsNotEqual(final Object one, final Object two) {

        return (one == null) ? (two != null) : (!one.equals(two));

    }
739999
@Override
  public int compare(S solution1, S solution2) {
    int result = rankComparator.compare(solution1, solution2) ;
    if (result == 0) {
      result = crowdingDistanceComparator.compare(solution1, solution2);
    }

    return result;
  }