/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
template<typename T>
class SkipListNode : private boost::noncopyable {
- enum {
+ enum : uint16_t {
IS_HEAD_NODE = 1,
MARKED_FOR_REMOVAL = (1 << 1),
FULLY_LINKED = (1 << 2),
};
+
public:
typedef T value_type;
height * sizeof(std::atomic<SkipListNode*>);
auto* node = static_cast<SkipListNode*>(alloc.allocate(size));
// do placement new
- new (node) SkipListNode(height, std::forward<U>(data), isHead);
+ new (node) SkipListNode(uint8_t(height), std::forward<U>(data), isHead);
return node;
}
SkipListNode* copyHead(SkipListNode* node) {
DCHECK(node != nullptr && height_ > node->height_);
setFlags(node->getFlags());
- for (int i = 0; i < node->height_; ++i) {
+ for (uint8_t i = 0; i < node->height_; ++i) {
setSkip(i, node->skip(i));
}
return this;
bool isHeadNode() const { return getFlags() & IS_HEAD_NODE; }
void setIsHeadNode() {
- setFlags(getFlags() | IS_HEAD_NODE);
+ setFlags(uint16_t(getFlags() | IS_HEAD_NODE));
}
void setFullyLinked() {
- setFlags(getFlags() | FULLY_LINKED);
+ setFlags(uint16_t(getFlags() | FULLY_LINKED));
}
void setMarkedForRemoval() {
- setFlags(getFlags() | MARKED_FOR_REMOVAL);
+ setFlags(uint16_t(getFlags() | MARKED_FOR_REMOVAL));
}
private: