Returns the next victim, excluding the newly added candidate. This exclusion is required so
that a candidate has a fair chance to be used, rather than always rejected due to existing
entries having a high frequency from the distant past.
559834
Node nextVictim(Node candidate) {
    if (policy == EvictionPolicy.MFU) {
      // highest, never the candidate
      return freq0.prev.nextNode.next;
    }

    // find the lowest that is not the candidate
    Node victim = freq0.next.nextNode.next;
    if (victim == candidate) {
      victim = (victim.next == victim.prev)
          ? victim.freq.next.nextNode.next
          : victim.next;
    }
    return victim;
  }
646691
def exclude_current_instance(self, queryset):
        
        if self.instance is not None:
            return queryset.exclude(pk=self.instance.pk)
        return queryset
1017784
def get_new_index(self):
        
        free_index = next(filterfalse(self.numbers.__contains__, count(0, 1)))
        self.numbers.add(free_index)
        return free_index
229437
def not_next(e):
    
    def match_not_next(s, grm=None, pos=0):
        try:
            e(s, grm, pos)
        except PegreError as ex:
            return PegreResult(s, Ignore, (pos, pos))
        else:
            raise PegreError('Negative lookahead failed', pos)
    return match_not_next
1078339
def _get_candidates(self):
        
        candidates = np.where(self.dpp_vector == 0)
        return None if len(candidates[0]) == 0 else candidates[0]
116250
private void expungeStaleEntries() {
	for (Object x; (x = queue.poll()) != null;) {
	    synchronized (queue) {
		@SuppressWarnings("unchecked")
		Entry<K, V> e = (Entry<K, V>) x;
		int i = indexFor(e.hash, table.length);

		Entry<K, V> prev = table[i];
		Entry<K, V> p = prev;
		while (p != null) {
		    Entry<K, V> next = p.next;
		    if (p == e) {
			if (prev == e) table[i] = next;
			else prev.next = next;
			// Must not null out e.next;
			// stale entries may be in use by a HashIterator
			e.value = null; // Help GC
			size--;
			break;
		    }
		    prev = p;
		    p = next;
		}
	    }
	}
    }
1046308
def next(self):
        
        if self._history_index == -1:
            return None

        new_index = self._history_index + 1
        connected = (
            new_index == len(self.model.state.entity_history(
                self.entity_type, self.entity_id)) - 1
        )
        return self.model.state.get_entity(
            self.entity_type, self.entity_id, self._history_index - 1,
            connected=connected)
890939
public synchronized Entry getNextEntry()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "getNextEntry");
    
    checkEntryParent();
    
    Entry nextEntry = null;
    
    synchronized(parentList)
    {
      if(atTop)
      {
        //if the cursor is at the top of the list, return the first entry in the list
        nextEntry = parentList.first;
      }
      else if(!atBottom)                        
      {
        //otherwise just return the next entry in the list
        nextEntry = current.getNext();                        
      }
      //if the cursor is at the bottom of the list then we should
      //just drop through and the next entry is null
    }
    
    if (tc.isEntryEnabled())
      SibTr.exit(tc, "getNextEntry", nextEntry);
    
    return nextEntry;
  }
265342
def next(self, match, predicate=None, index=None):
        
        current = match.start + 1
        while current <= self._max_end:
            next_matches = self.starting(current)
            if next_matches:
                return filter_index(next_matches, predicate, index)
            current += 1
        return filter_index(_BaseMatches._base(), predicate, index)
1330755
def _next_sample_index(self):
        
        return self.rng.choice(self.n_streams,
                               p=(self.stream_weights_ /
                                  self.weight_norm_))
265837
def get_next_occurrence(self) -> date:
        
        result = get_next_occurrence(self.transaction)
        assert isinstance(result, date)
        return result
703304
def try_next(self):
        
        with self.condition:
            try:
                return self.force[0]
            except IndexError:
                pass

            return self._get_next(False)
372298
protected int getCurrentSelection() {
        if (mCurrentProfile != null && mProfiles != null) {
            int i = 0;
            for (IProfile profile : mProfiles) {
                if (profile == mCurrentProfile) {
                    return i;
                }
                i++;
            }
        }
        return -1;
    }
984732
public synchronized Object getNextJob()
    {
        Object strJobDef = null;
        synchronized (this)
        {
            if (m_vPrivateJobs.size() > 0)
                strJobDef = m_vPrivateJobs.remove(0);
        }
        return strJobDef;
    }
661395
public synchronized Entry previous()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "previous");

//  can only do anything if the cursor is still pointing in to a list
    checkEntryParent();
  
    Entry previousEntry = null;
  
    synchronized(parentList)
    {
      //get the previous entry
      previousEntry = getPreviousEntry();
      //if it is null
      if(previousEntry == null)
      {
        //then hopefully we are at the top of the list
        if(current == parentList.first)
        {
          //so move the cursor to the top
          moveToTop();
        }
        else if(!atTop)
        {
          //it should not be possible for the previous entry to be null but the current
          //not be the first one in the list or already at the top
          SIErrorException e = new SIErrorException(
            nls.getFormattedMessage(
              "INTERNAL_MESSAGING_ERROR_CWSIP0002",
              new Object[] {
                "com.ibm.ws.sib.processor.utils.linkedlist.Cursor",
                "1:228:1.15" },
             null));
    
          FFDCFilter.processException(
            e,
            "com.ibm.ws.sib.processor.utils.linkedlist.Cursor.previous",
            "1:234:1.15",
            this);
      
          SibTr.exception(tc, e);      
    
          if (tc.isEntryEnabled())
            SibTr.exit(tc, "previous", e);
    
          throw e;
        }
      }
      else
      {
        //move the cursor to the previous entry
        moveCursor(previousEntry); 
      }
    }
  
    if (tc.isEntryEnabled())
      SibTr.exit(tc, "previous", previousEntry);

    return previousEntry;
  }
1071894
def lastId(self) -> BaseReference:
        
        if self.childIds is not None:
            if len(self.childIds) > 0:
                return self.childIds[-1]
            return None
        else:
            raise NotImplementedError
941643
def get_next_action(self, request, application, label, roles):
        

        # if user is logged and and not applicant, steal the
        # application
        if 'is_applicant' in roles:
            # if we got this far, then we either we are logged in as applicant,
            # or we know the secret for this application.

            new_person = None
            reason = None
            details = None

            attrs, _ = saml.parse_attributes(request)
            saml_id = attrs['persistent_id']
            if saml_id is not None:
                query = Person.objects.filter(saml_id=saml_id)
                if application.content_type.model == "person":
                    query = query.exclude(pk=application.applicant.pk)
                if query.count() > 0:
                    new_person = Person.objects.get(saml_id=saml_id)
                    reason = "SAML id is already in use by existing person."
                    details = (
                        "It is not possible to continue this application "
                        + "as is because the saml identity already exists "
                        + "as a registered user.")
                del query

            if request.user.is_authenticated:
                new_person = request.user
                reason = "%s was logged in " \
                    "and accessed the secret URL." % new_person
                details = (
                    "If you want to access this application "
                    + "as %s " % application.applicant
                    + "without %s stealing it, " % new_person
                    + "you will have to ensure %s is " % new_person
                    + "logged out first.")

            if new_person is not None:
                if application.applicant != new_person:
                    if 'steal' in request.POST:
                        old_applicant = application.applicant
                        application.applicant = new_person
                        application.save()
                        log.change(
                            application.application_ptr,
                            "Stolen application from %s" % old_applicant)
                        messages.success(
                            request,
                            "Stolen application from %s" % old_applicant)
                        url = base.get_url(request, application, roles, label)
                        return HttpResponseRedirect(url)
                    else:
                        return render(
                            template_name='kgapplications'
                            '/project_aed_steal.html',
                            context={
                                'application': application,
                                'person': new_person,
                                'reason': reason,
                                'details': details,
                            },
                            request=request)

        # if the user is the leader, show him the leader specific page.
        if ('is_leader' in roles or 'is_delegate' in roles) \
                and 'is_admin' not in roles \
                and 'is_applicant' not in roles:
            actions = ['reopen']
            if 'reopen' in request.POST:
                return 'reopen'
            return render(
                template_name='kgapplications/project_aed_for_leader.html',
                context={'application': application,
                         'actions': actions, 'roles': roles, },
                request=request)

        # otherwise do the default behaviour for StateWithSteps
        return super(StateApplicantEnteringDetails, self) \
            .get_next_action(request, application, label, roles)