this method returns the pointer to the loser in the competition for survival;
516606
public static Program compete(List<Program> programs, Program current, Program candidate, LGP manager, RandEngine randEngine) {
      if(manager.getReplacementStrategy() == LGPReplacementStrategy.DirectCompetition) {
         if (CollectionUtils.isBetterThan(candidate, current)) {
            int index = programs.indexOf(current);
            programs.set(index, candidate);
            return current;
         }
         else {
            return candidate;
         }
      } else {
         if(randEngine.uniform() <= manager.getReplacementProbability()){
            int index = programs.indexOf(current);
            programs.set(index, candidate);
            return current;
         } else {
            return candidate;
         }
      }
   }
145976
private int endCheckIf()
    {
        Node th, el;
        int rv = END_UNREACHED;

        th = next;
        el = ((Jump)this).target;

        rv = th.endCheck();

        if (el != null)
            rv |= el.endCheck();
        else
            rv |= END_DROPS_OFF;

        return rv;
    }
318484
private void processIntegerReturn() {
        if ((sawConstant == null) && (stack.getStackDepth() == 0)) {
            throw new StopOpcodeParsingException();
        }

        Integer returnValue = null;
        if (sawConstant == null) {
            OpcodeStack.Item item = stack.getStackItem(0);
            returnValue = (Integer) item.getConstant();
        } else {
            returnValue = sawConstant;
        }

        if (returnValue == null) {
            throw new StopOpcodeParsingException();
        }
        int v = returnValue.intValue();
        if (v < 0) {
            seenNegative = true;
            if (getPC() > furthestBranchTarget) {
                seenUnconditionalNonZero = true;
            }
        } else if (v > 0) {
            seenPositive = true;
            if (getPC() > furthestBranchTarget) {
                seenUnconditionalNonZero = true;
            }
        } else {
            seenZero = true;
        }

        sawConstant = null;
    }
531880
private int sequentialFindDelete(
    int              lower,
    int              upper,
    Object           delKey)
  {
    java.util.Comparator comp = deleteComparator();
    int xcc;                       /* Current compare result                */
    int idx = -1;                  /* The returned index (-1 if not found)  */
    for (int i = lower; i <= upper; i++)
    {
      xcc = comp.compare(delKey, _nodeKey[i]);
      if (xcc == 0)                /* Found a match                         */
        {
          idx = i;                 /* Remember current point                */
          break;
        }
    }
    return idx;
  }
1013018
public MethodState getSaved(int idx) {
        if (idx < 0) {
            throw new IllegalArgumentException();
        }

        MethodState state = firstPointer;
        for (int i = 0; i < idx; i++) {
            state = state.getNext();
            if (state == null) {
               throw new IllegalArgumentException();
            }
        }
        return state;
    }
106589
def getPointer(p)
      # puts "getPointer >> p=#{p}"
      return nil if p > @nitems || p < 0
      pos = SIZEOF_BLOCK_HEADER + (SIZEOF_KEY * @nitems) + (SIZEOF_POINTER * p)
      ptrdata = @data[pos, SIZEOF_POINTER]
      POINTER.decode(ptrdata)
    end
1250113
InvocationCallback queuePoll() {
      InvocationCallback element;
      synchronized (this) {
         if (tail != head) {
            element = elements[head & mask];
            head++;
         } else {
            element = null;
            frozen = true;
         }
      }
      return element;
   }
501076
private static double ar(AssociativeArray2D survivalFunction, int r) {
        if(survivalFunction.isEmpty()) {
            throw new IllegalArgumentException("The provided collection can't be empty.");
        }
        
        AssociativeArray2D survivalFunctionCopy = survivalFunction;
        
        //check if last one is censored and close it
        Map.Entry<Object, AssociativeArray> lastRowEntry = null;
        for(Map.Entry<Object, AssociativeArray> currentRowEntry : survivalFunction.entrySet()) {
            lastRowEntry=currentRowEntry;
        }
        
        if(lastRowEntry==null) {
            throw new IllegalArgumentException("The last observation can't be censored.");
        }
        
        AssociativeArray lastRow = lastRowEntry.getValue();
        if(lastRow.get("Sti")==null) { //if the last record is censored we must close the line
            survivalFunctionCopy = survivalFunction.copy(); //copy internalData to avoid modifying the internalData
            
            Object lastRowKey = lastRowEntry.getKey();
            AssociativeArray lastRowValue = survivalFunctionCopy.remove(lastRowKey);
            
            String str = lastRowKey.toString();
            Double newLastRowKey = Double.valueOf(str.substring(0,str.length()-CENSORED_NUMBER_POSTFIX.length())); //remove censored postfix
            newLastRowKey = Math.floor(newLastRowKey)+1;
            
            survivalFunctionCopy.put2d(newLastRowKey, "i", lastRowValue.get("i"));
            survivalFunctionCopy.put2d(newLastRowKey, "r", lastRowValue.get("i"));
            survivalFunctionCopy.put2d(newLastRowKey, "Sti", 0.0);
            survivalFunctionCopy.put2d(newLastRowKey, "varianceSti", 0.0);
        }
        

        double Ar=0.0;
        double StiPrevious=1;
        double tiPrevious=0;
        for(Map.Entry<Object, AssociativeArray> entry : survivalFunctionCopy.entrySet()) {
            Object ti = entry.getKey();
            AssociativeArray row = entry.getValue();
            

            Double Sti = row.getDouble("Sti");
            
            if(Sti==null) {
                continue; //skip censored internalData
            }
            
            double tiCurrent = Double.valueOf(ti.toString());
            if(row.getDouble("r")>r) {
                Ar+=StiPrevious*(tiCurrent-tiPrevious);
            }
            StiPrevious=Sti;
            tiPrevious=tiCurrent;
        }

        return Ar;
    }
600798
def get_winner(trials):
    """"""
    winner = {}
    # TODO: sort_key should be customized here
    sort_key = "accuracy"
    if trials and len(trials) > 0:
        first_metrics = get_trial_info(trials[0])["metrics"]
        if first_metrics and not first_metrics.get("accuracy", None):
            sort_key = "episode_reward"
        max_metric = float("-Inf")
        for t in trials:
            metrics = get_trial_info(t).get("metrics", None)
            if metrics and metrics.get(sort_key, None):
                current_metric = float(metrics[sort_key])
                if current_metric > max_metric:
                    winner["trial_id"] = t.trial_id
                    winner["metric"] = sort_key + ": " + str(current_metric)
                    max_metric = current_metric
    return winner
530826
def reverse
      return unless @opponent
      r = Result.new(@round, @opponent, @score == 'W' ? 'L' : (@score == 'L' ? 'W' : 'D'))
      r.opponent = @player
      r.colour = 'W' if @colour == 'B'
      r.colour = 'B' if @colour == 'W'
      r.rateable = @rateable
      r
    end
1090979
private void leftDeleteNoPredecessor(
                                        GBSNode           p,
                                        Object            deleteKey,
                                        DeleteNode        point)
    {
        int idx = p.findDeleteInLeft(deleteKey);
        if (idx >= 0)
            point.setDelete(p, idx);
    }
1268096
def result(self):
        
        if self.exception():
            raise self.exception()
        # Otherwise return a context manager that cleans up after the block.

        @contextlib.contextmanager
        def f():
            try:
                yield self._wrapped.result()
            finally:
                self._exit_callback()
        return f()
1085344
def coombstoc_winners(self, profile):
        
        ordering = profile.getOrderVectors()
        m = profile.numCands
        prefcounts = profile.getPreferenceCounts()
        rankmaps = profile.getRankMaps()
        if min(ordering[0]) == 0:
            startstate = set(range(m))
        else:
            startstate = set(range(1, m + 1))
        known_winners = set()
        # half = math.floor(n / 2.0)
        # ----------Some statistics--------------
        hashtable2 = set()

        # push the node of start state into the priority queue
        root = Node(value=startstate)
        stackNode = []
        stackNode.append(root)

        while stackNode:
            # ------------pop the current node----------------
            node = stackNode.pop()
            # -------------------------------------------------
            state = node.value.copy()
            # use heuristic to delete all the candidates which satisfy the following condition

            # goal state 1: if the state set contains only 1 candidate, then stop
            if len(state) == 1 and list(state)[0] not in known_winners:
                known_winners.add(list(state)[0])
                continue
            # goal state 2 (pruning): if the state set is subset of the known_winners set, then stop
            if state <= known_winners:
                continue
            # ----------Compute plurality score for the current remaining candidates-------------
            reverse_veto_score = self.get_reverse_veto_scores2(prefcounts, rankmaps, state)
            # print("reverse_veto_score = ",reverse_veto_score)

            # if current state satisfies one of the 3 goal state, continue to the next loop

            # After using heuristics, generate children and push them into priority queue
            # frontier = [val for val in known_winners if val in state] + list(set(state) - set(known_winners))

            maxscore = max(reverse_veto_score.values())
            for to_be_deleted in state:
                if reverse_veto_score[to_be_deleted] == maxscore:
                    child_state = state.copy()
                    child_state.remove(to_be_deleted)
                    tpc = tuple(sorted(child_state))
                    if tpc in hashtable2:
                        continue
                    else:
                        hashtable2.add(tpc)
                        child_node = Node(value=child_state)
                        stackNode.append(child_node)
        return sorted(known_winners)
180920
function(client) {
            if(client.debug >= 1)
                client.log(client.balls[client.leaders[0]] + ' WON THE GAME! Server going for restart');

            client.emitEvent('winner', client.leaders[0]);
        }
450229
public int getReturnCode() {
        long returnCode = this.stagingByteBuffer.getLong(RETURN_CODE_INDEX * 8);
        if (returnCode > Integer.MAX_VALUE) {
            AsyncException ae = new AsyncException("Return code value invalid");
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Invalid value returned for return code, exception: " + ae.getMessage());
            }
            FFDCFilter.processException(ae, getClass().getName(), "227", this);
            return Integer.MAX_VALUE;
        }
        return (int) returnCode;
    }
610465
def getchallenge(self):
        ""
        self.sock.send(CHALLENGE_PACKET)
        # wait challenge response
        for packet in self.read_iterator(self.CHALLENGE_TIMEOUT):
            if packet.startswith(CHALLENGE_RESPONSE_HEADER):
                return parse_challenge_response(packet)
942806
def tournament(self, negative=False):
        """"""
        if self.generation <= self._random_generations and not negative:
            return self.random_selection()
        if not self._negative_selection and negative:
            return self.random_selection(negative=negative)
        vars = self.random()
        fit = [(k, self.population[x].fitness) for k, x in enumerate(vars)]
        if negative:
            fit = min(fit, key=lambda x: x[1])
        else:
            fit = max(fit, key=lambda x: x[1])
        index = fit[0]
        return vars[index]