Rename oldkey into newkey but fails if the destination key newkey already exists.
<p>
Time complexity: O(1)
@param oldkey
@param newkey
@return Integer reply, specifically: 1 if the key was renamed 0 if the target key already exist
496748
@Override
  public Long renamenx(final byte[] oldkey, final byte[] newkey) {
    checkIsInMultiOrPipeline();
    client.renamenx(oldkey, newkey);
    return client.getIntegerReply();
  }
794283
protected boolean renameClientObject (Name oldname, Name newname)
    {
        ClientObject clobj = _objmap.remove(oldname);
        if (clobj == null) {
            log.warning("Requested to rename unmapped client object", "username", oldname,
                        new Exception());
            return false;
        }
        _objmap.put(newname, clobj);
        return true;
    }
1172633
public long remove(K key) {
    AtomicLong atomic = map.get(key);
    if (atomic == null) {
      return 0L;
    }

    for (;;) {
      long oldValue = atomic.get();
      if (oldValue == 0L || atomic.compareAndSet(oldValue, 0L)) {
        // only remove after setting to zero, to avoid concurrent updates
        map.remove(key, atomic);
        // succeed even if the remove fails, since the value was already adjusted
        return oldValue;
      }
    }
  }
725718
public function renameForeignKey($oldName, $newName)
    {
        if (!$this->hasForeignKey($oldName)) {
            throw SchemaException::tableForeignKeyDoesNotExist($this->getName(), $oldName);
        }

        if ($this->hasForeignKey($newName)) {
            throw SchemaException::tableForeignKeyAlreadyExists($this->getName(), $newName);
        }

        $this->foreignKeys[$oldName]->setName($newName);
        $this->foreignKeys[$newName] = $this->foreignKeys[$oldName];
        unset($this->foreignKeys[$oldName]);
    }
241458
private static String getInnerMapKey(final String key) {
        final int index = key.indexOf(".");
        return key.substring(index + 1);
    }
52988
def create_from_key(cls, oldvalue, key):
    ""
    if oldvalue is not None:
        raise AlreadyExistsException('%r already exists' % (oldvalue,))
    return cls.create_from_key(key)
492494
public void rename(String oldName, String newName)
        throws IOException, ServerException {
        if (oldName == null || newName == null) {
            throw new IllegalArgumentException("Required argument missing");
        }
        Command cmd = new Command("RNFR", oldName);
        try {
            Reply reply = controlChannel.exchange(cmd);
            if (!Reply.isPositiveIntermediate(reply)) {
                throw new UnexpectedReplyCodeException(reply);
            }
            controlChannel.execute(new Command("RNTO", newName));
        } catch (FTPReplyParseException rpe) {
            throw ServerException.embedFTPReplyParseException(rpe);
        } catch (UnexpectedReplyCodeException urce) {
            throw ServerException.embedUnexpectedReplyCodeException(
                                urce,
                                "Server refused renaming file");
        }
    }
406596
protected function remapRecursively(&$data, $oldKey, $newKey)
    {
        $data->loopThrough(function ($index, $value) use ($data, $oldKey, $newKey) {
            $matches = $this->checkRegexRecursively($value, $oldKey, $index);
            foreach ($matches as $match) {
                $this->remap($data, $match[0], $this->getRegexProperty($match, $newKey));
            }
        });
    }
886521
def renamenx(self, key, newkey):
        
        if key == newkey:
            raise ValueError("key and newkey are the same")
        fut = self.execute(b'RENAMENX', key, newkey)
        return wait_convert(fut, bool)
827657
@SuppressWarnings("unchecked")
    private void comparableDecreaseKey(Node<K, V> n, K newKey) {
        int c = ((Comparable<? super K>) newKey).compareTo(n.key);
        if (c > 0) {
            throw new IllegalArgumentException("Keys can only be decreased!");
        }
        n.key = newKey;
        if (c == 0) {
            return;
        }

        if (n.next == null) {
            throw new IllegalArgumentException("Invalid handle!");
        }

        // if not root and heap order violation
        Node<K, V> y = n.parent;
        if (y != null && ((Comparable<? super K>) n.key).compareTo(y.key) < 0) {
            cut(n, y);
            root.mark = false;
            cascadingRankChange(y);
            if (((Comparable<? super K>) n.key).compareTo(root.key) < 0) {
                root = link(root, n);
            } else {
                link(n, root);
            }
        }
    }
1245850
def rename(self, old_key, new_key):
        
        return lib.zhash_rename(self._as_parameter_, old_key, new_key)
377221
private boolean renameKeyForAllLanguages(String oldKey, String newKey) {

        try {
            loadAllRemainingLocalizations();
            lockAllLocalizations(oldKey);
            if (hasDescriptor()) {
                lockDescriptor();
            }
        } catch (CmsException | IOException e) {
            LOG.error(e.getLocalizedMessage(), e);
            return false;
        }
        for (Entry<Locale, SortedProperties> entry : m_localizations.entrySet()) {
            SortedProperties localization = entry.getValue();
            if (localization.containsKey(oldKey)) {
                String value = localization.getProperty(oldKey);
                localization.remove(oldKey);
                localization.put(newKey, value);
                m_changedTranslations.add(entry.getKey());
            }
        }
        if (hasDescriptor()) {
            CmsXmlContentValueSequence messages = m_descContent.getValueSequence(
                Descriptor.N_MESSAGE,
                Descriptor.LOCALE);
            for (int i = 0; i < messages.getElementCount(); i++) {

                String prefix = messages.getValue(i).getPath() + "/";
                String key = m_descContent.getValue(prefix + Descriptor.N_KEY, Descriptor.LOCALE).getStringValue(m_cms);
                if (key == oldKey) {
                    m_descContent.getValue(prefix + Descriptor.N_KEY, Descriptor.LOCALE).setStringValue(m_cms, newKey);
                    break;
                }
            }
            m_descriptorHasChanges = true;
        }
        m_keyset.renameKey(oldKey, newKey);
        return true;
    }
1084557
public final void updateKey(String key) throws IOException {
    Objects.requireNonNull(key, "old key required");
    if (index.containsKey(key)) {
      MtasSolrStatus status = index.get(key);
      index.remove(key);
      if (!index.containsKey(status.key())) {
        index.put(status.key(), status);
      } else {
        throw new IOException("key already exists");
      }
    }
  }
299360
public Response rename(String bucket, String oldFileKey, String newFileKey, boolean force)
            throws QiniuException {
        return move(bucket, oldFileKey, bucket, newFileKey, force);
    }
1346885
private String getReplacement(String key) {
    Result result = results.get(key);
    if (result != null) {
      return result.replacement;
    }

    String replacement = nameGenerator.generateNextName();
    result = new Result(key, replacement);
    results.put(key, result);
    return replacement;
  }
1353665
public String getName(String oldName) {
        if (oldName != null && this.existing.containsKey(oldName)) {
            return this.existing.get(oldName);
        }

        final String name = this.prefix + this.counter;
        this.counter++;

        if (oldName != null) {
            this.existing.put(oldName, name);
        }

        return name;
    }
1014795
def od_reorder_keys(od, keys_in_new_order): # not used
    '''
    
    '''
    if set(od.keys()) != set(keys_in_new_order):
        raise KeyError('Keys in the new order do not match existing keys')
    for key in keys_in_new_order:
        od[key] = od.pop(key)
    return od