X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FConcurrentSkipList.h;h=ff84de41804926b20221366bc72b6cf53e3513c6;hb=0a19e9388bd6768f75c6b53b1d775ab169b81da1;hp=0cf05f1966e068ddf6323b70498887292ff46075;hpb=406822b8462145dc26be2a1a837eda9c6706dfb2;p=folly.git diff --git a/folly/ConcurrentSkipList.h b/folly/ConcurrentSkipList.h index 0cf05f19..ff84de41 100644 --- a/folly/ConcurrentSkipList.h +++ b/folly/ConcurrentSkipList.h @@ -1,5 +1,5 @@ /* - * Copyright 2015 Facebook, Inc. + * Copyright 2016 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -117,8 +117,7 @@ Sample usage: } */ -#ifndef FOLLY_CONCURRENT_SKIP_LIST_H_ -#define FOLLY_CONCURRENT_SKIP_LIST_H_ +#pragma once #include #include @@ -161,22 +160,35 @@ class ConcurrentSkipList { class Accessor; class Skipper; - explicit ConcurrentSkipList(int height, const NodeAlloc& alloc = NodeAlloc()) - : recycler_(alloc), - head_(NodeType::create(recycler_.alloc(), height, value_type(), true)), - size_(0) { } + explicit ConcurrentSkipList(int height, const NodeAlloc& alloc) + : recycler_(alloc), + head_(NodeType::create(recycler_.alloc(), height, value_type(), true)), + size_(0) {} + + explicit ConcurrentSkipList(int height) + : recycler_(), + head_(NodeType::create(recycler_.alloc(), height, value_type(), true)), + size_(0) {} // Convenient function to get an Accessor to a new instance. - static Accessor create(int height = 1, const NodeAlloc& alloc = NodeAlloc()) { + static Accessor create(int height, const NodeAlloc& alloc) { return Accessor(createInstance(height, alloc)); } + static Accessor create(int height = 1) { + return Accessor(createInstance(height)); + } + // Create a shared_ptr skiplist object with initial head height. - static std::shared_ptr createInstance( - int height = 1, const NodeAlloc& alloc = NodeAlloc()) { + static std::shared_ptr createInstance(int height, + const NodeAlloc& alloc) { return std::make_shared(height, alloc); } + static std::shared_ptr createInstance(int height = 1) { + return std::make_shared(height); + } + //=================================================================== // Below are implementation details. // Please see ConcurrentSkipList::Accessor for stdlib-like APIs. @@ -787,5 +799,3 @@ class ConcurrentSkipList::Skipper { }; } // namespace folly - -#endif // FOLLY_CONCURRENT_SKIP_LIST_H_