Add or remove token to/from list.

        If token is in this list, the token will be removed. Otherwise add it
        to list.
512067
def toggle(self, token: str) -> None:
        
        self._validate_token(token)
        if token in self:
            self.remove(token)
        else:
            self.add(token)
285591
def remove(self, element):
        """"""
        try:
            index = self.index(element)
        except ValueError:
            raise ValueError("list.remove(x): x not in list")
        else:
            self._notify_remove_at(index)
            super(ObservableList, self).pop(index)
93390
private void addToList(List<Object> list, Object value) {
    if (value instanceof List) {
      list.addAll((List) value);
    } else {
      list.add(value);
    }
  }
913820
public void removeToken(String name) {
        if (name == null || name.isEmpty()) {
            return;
        }

        for (Iterator<AntiCsrfParamToken> it = tokens.iterator(); it.hasNext();) {
            AntiCsrfParamToken token = it.next();
            if (name.equals(token.getName())) {
                it.remove();
                if (token.isEnabled()) {
                    this.enabledTokensNames.remove(name);
                }
                break;
            }
        }
    }
187748
def add_to_list
      if in_list?
        move_to_bottom
      else
        list_class.transaction do
          ids = lock_list!
          last_position = ids.size
          if persisted?
            update_position last_position + 1
          else
            set_position last_position + 1
          end
        end
      end
    end
336140
public function merge(TokenList $tokenList) {
        $tokenList->closeOpenTokens();
        $lastTokenPosition = $this->last() === null ? 0 : $this->last()
            ->getPosition();
        foreach ($tokenList->getTokens() as $token) {
            $token->setPosition($token->getPosition() + $lastTokenPosition);
            $this->tokens[] = $token;
        }
    }
552916
public void remove( Token token ) {
        if( token == first ) {
            first = first.next;
        }
        if( token == last ) {
            last = last.previous;
        }
        if( token.next != null ) {
            token.next.previous = token.previous;
        }
        if( token.previous != null ) {
            token.previous.next = token.next;
        }

        token.next = token.previous = null;
        size--;
    }
952741
public void addValue(Token[] tokens) {
        if (type == null) {
            type = ItemType.LIST;
        }
        if (!isListableType()) {
            throw new IllegalArgumentException("The type of this item must be 'array', 'list' or 'set'");
        }
        if (tokensList == null) {
            tokensList = new ArrayList<>();
        }
        tokensList.add(tokens);
    }
61489
private function addTokenToVector($token, $field, $count = 1)
    {
        if (!empty($token)) {
            if (isset($this->tokenVector[$field][$token])) {
                $this->tokenVector[$field][$token] += $count;
            } else {
                $this->tokenVector[$field][$token] = $count;
            }
        }
    }
1334068
private void addTokens(List<AnalyzedToken> taggedTokens, List<AnalyzedToken> l) {
    if (taggedTokens != null) {
      for (AnalyzedToken at : taggedTokens) {
        l.add(at);
      }
    }
  }
645877
private void addGroup(List<Token> group, List<List<Token>> groups) {

    if(group.isEmpty()) return;

    // remove trailing tokens that should be ignored
    while(!group.isEmpty() && IGNORED_TRAILING_TOKENS.contains(
        group.get(group.size() - 1).getType())) {
      group.remove(group.size() - 1);
    }

    // if the group still has some tokens left, we'll add it to our list of groups
    if(!group.isEmpty()) {
      groups.add(group);
    }
  }
442469
public void deleteToken(String token, DeleteTokenHandler handler) {
        HMSAgentLog.i("deleteToken:token:" + StrUtils.objDesc(token) + " handler=" + StrUtils.objDesc(handler));
        this.token = token;
        this.handler = handler;
        connect();
    }
1000708
protected function addToListBottom()
    {
        if ($this->isInList()) return;

        $newPosition = $this->getBottomPositionValue();

        if (null === $newPosition) {
            $newPosition = $this->listifyTop();
        } else {
            $newPosition += 1;
        }

        $this->setListifyPosition($newPosition);
    }
513935
public boolean add(Token token,
                       Transaction transaction)
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass,
                        "add",
                        new Object[] { token, transaction });

        List.Entry newEntry = null;
        // Lock the tailSequenceNumber until the new link is in the list.
        // This prevents the possibility that after we had incremented the tail sequence number
        // but before we had added it to the subList some thread resets the headSequenceNumber 
        // and skipped passed the link we just added.
        synchronized (transaction.internalTransaction) {
            tailSequenceNumberLock.lock();
            try {
                if (!tailSequenceNumberSet)
                    resetTailSequenceNumber();
                // Establish the sequenceNumber of this Object in the overall list.
                long usableTailSequenceNumber = ++tailSequenceNumber;

                // Figure out which subList the Object should be added to.
                ConcurrentSubList list = getSublist(usableTailSequenceNumber);
                // Add the link near the tail of the list according to its assigned
                // sequence number.
                newEntry = list.addEntry(token,
                                         transaction,
                                         usableTailSequenceNumber,
                                         this);
            } finally {
                if (tailSequenceNumberLock.isHeldByCurrentThread())
                    tailSequenceNumberLock.unlock();
            } // try (tailSequenceNumberLock).
        } // synchronized (transaction.internalTransaction).

        boolean modified = (newEntry != null);
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass,
                       "add",
                       new Object[] { new Boolean(modified) });
        return modified;
    }
455113
private void addTokens(final Token curToken, final List<Token> tokens) {
    if (curToken.tokenLength() != 0) {
      if (this.unTokenizable) {
        tokens.add(curToken);
      } else if (!this.unTokenizable) {
        if (!replacement.matcher(curToken.getTokenValue()).matches()) {
          tokens.add(curToken);
        }
      }
    }
  }
420212
def remove_token(self, token_stack, token):
        """"""
        token_stack.reverse()
        try:
            token_stack.remove(token)
            retval = True
        except ValueError:
            retval = False
        token_stack.reverse()
        return retval
1220206
public static <E, T extends E> void add(List<E> list, int index, T item){
        if(index<list.size())
            list.add(index, item);
        else
            list.add(item);
    }