/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2011-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// Returns the node if found, nullptr otherwise.
NodeType* find(const value_type &data) {
auto ret = findNode(data);
- if (ret.second && !ret.first->markedForRemoval()) return ret.first;
+ if (ret.second && !ret.first->markedForRemoval()) {
+ return ret.first;
+ }
return nullptr;
}
nodeToDelete = succs[layer];
nodeHeight = nodeToDelete->height();
nodeGuard = nodeToDelete->acquireGuard();
- if (nodeToDelete->markedForRemoval()) return false;
+ if (nodeToDelete->markedForRemoval()) {
+ return false;
+ }
nodeToDelete->setMarkedForRemoval();
isMarked = true;
}
for (int layer = maxLayer(); layer >= 0; --layer) {
do {
node = pred->skip(layer);
- if (node) pred = node;
+ if (node) {
+ pred = node;
+ }
} while (node != nullptr);
}
return pred == head_.load(std::memory_order_relaxed)
while (!found) {
// stepping down
for (; ht > 0 && less(data, node = pred->skip(ht - 1)); --ht) {}
- if (ht == 0) return std::make_pair(node, 0); // not found
+ if (ht == 0) {
+ return std::make_pair(node, 0); // not found
+ }
// node <= data now, but we need to fix up ht
--ht;
explicit csl_iterator(NodeT* node = nullptr) : node_(node) {}
template <typename OtherVal, typename OtherNode>
- csl_iterator(const csl_iterator<OtherVal, OtherNode> &other,
- typename std::enable_if<std::is_convertible<OtherVal, ValT>::value>::type*
- = 0) : node_(other.node_) {}
+ csl_iterator(
+ const csl_iterator<OtherVal, OtherNode>& other,
+ typename std::enable_if<
+ std::is_convertible<OtherVal, ValT>::value>::type* = nullptr)
+ : node_(other.node_) {}
size_t nodeSize() const {
return node_ == nullptr ? 0 :
*/
bool to(const value_type &data) {
int layer = curHeight() - 1;
- if (layer < 0) return false; // reaches the end of the list
+ if (layer < 0) {
+ return false; // reaches the end of the list
+ }
int lyr = hints_[layer];
int max_layer = maxLayer();
int foundLayer = SkipListType::
findInsertionPoint(preds_[lyr], lyr, data, preds_, succs_);
- if (foundLayer < 0) return false;
+ if (foundLayer < 0) {
+ return false;
+ }
DCHECK(succs_[0] != nullptr) << "lyr=" << lyr
<< "; max_layer=" << max_layer;