Skip to content

TDeque to std::deque #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions client/ydb_coordination/coordination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class TSessionContext : public TThrRefBase {
TIntrusivePtr<TSemaphoreOp> LastSentOp;
TIntrusivePtr<TSemaphoreOp> LastAckedOp;
THashMap<ui64, TIntrusivePtr<TSemaphoreOp>> WaitingOps;
TDeque<TIntrusivePtr<TSemaphoreOp>> OpQueue;
std::deque<TIntrusivePtr<TSemaphoreOp>> OpQueue;
bool Restoring = false;

bool IsEmpty() const {
Expand Down Expand Up @@ -874,9 +874,9 @@ class TSessionContext : public TThrRefBase {
bool notifyExpired = false;
TPromise<TSessionResult> sessionPromise;
TResultPromise<void> reconnectPromise;
TDeque<TResultPromise<bool>> abortedSemaphoreOps;
TDeque<TResultPromise<bool>> failedSemaphoreOps;
TDeque<THolder<TSimpleOp>> failedSimpleOps;
std::deque<TResultPromise<bool>> abortedSemaphoreOps;
std::deque<TResultPromise<bool>> failedSemaphoreOps;
std::deque<THolder<TSimpleOp>> failedSimpleOps;
TResultPromise<void> closePromise;

{
Expand Down Expand Up @@ -1010,7 +1010,7 @@ class TSessionContext : public TThrRefBase {
sessionPromise.SetValue(TSessionResult(status));
}

if (abortedSemaphoreOps) {
if (!abortedSemaphoreOps.empty()) {
auto aborted = MakeStatus(EStatus::ABORTED,
"Operation superseded by another request, true result has been lost");
for (auto& promise : abortedSemaphoreOps) {
Expand Down Expand Up @@ -1765,7 +1765,7 @@ class TSessionContext : public TThrRefBase {

THashMap<std::string, TSemaphoreState> Semaphores;
THashMap<ui64, TSemaphoreState*> SemaphoreByReqId;
TDeque<THolder<TSimpleOp>> PendingRequests;
std::deque<THolder<TSimpleOp>> PendingRequests;
THashMap<ui64, THolder<TSimpleOp>> SentRequests;
TResultPromise<void> ReconnectPromise;

Expand Down
2 changes: 1 addition & 1 deletion client/ydb_persqueue_core/ut/ut_utils/ut_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct TYDBClientEventLoop : public ::NPersQueue::IClientEventLoop {
std::optional<TContinuationToken> continueToken;
NThreading::TFuture<void> waitEventFuture = writer->WaitEvent();
THashMap<ui64, NThreading::TPromise<::NPersQueue::TWriteResult>> ackPromiseBySequenceNumber;
TDeque<NThreading::TPromise<::NPersQueue::TWriteResult>> ackPromiseQueue;
std::deque<NThreading::TPromise<::NPersQueue::TWriteResult>> ackPromiseQueue;
while (!MustStop) {
if (!continueToken) {
Log << TLOG_INFO << "Wait for writer event";
Expand Down
2 changes: 1 addition & 1 deletion library/cpp/blockcodecs/core/codecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace {
Registry[Tmp.back()] = Registry[to];
}

TDeque<std::string> Tmp;
std::deque<std::string> Tmp;
TNullCodec Null;
std::vector<TCodecPtr> Codecs;
typedef THashMap<std::string_view, ICodec*> TRegistry;
Expand Down
4 changes: 2 additions & 2 deletions library/cpp/coroutine/engine/stack/stack_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ namespace NCoro::NStack {
void ReleaseMemory(char* alignedStackMemory, size_t pagesToKeep) noexcept;

private:
TDeque<void*> Released_; //!< stacks memory with released RSS memory
TDeque<void*> Full_; //!< stacks memory with RSS memory
std::deque<void*> Released_; //!< stacks memory with released RSS memory
std::deque<void*> Full_; //!< stacks memory with RSS memory
size_t StackSize_ = 0;
size_t RssPagesToKeep_ = 0;
const size_t ReleaseRate_ = 1;
Expand Down
2 changes: 1 addition & 1 deletion library/cpp/dbg_output/dumpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct TDumper<std::array<T, N>>: public TSeqDumper {
};

template <class T, class A>
struct TDumper<TDeque<T, A>>: public TSeqDumper {
struct TDumper<std::deque<T, A>>: public TSeqDumper {
};

template <class T, class A>
Expand Down
1 change: 1 addition & 0 deletions library/cpp/dbg_output/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <string>
#include <utility>
#include <deque>

template <class T>
struct TDumper {
Expand Down
3 changes: 2 additions & 1 deletion library/cpp/http/io/compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <util/generic/deque.h>
#include <util/generic/hash.h>


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пробел лишний

class TCompressionCodecFactory {
public:
using TDecoderConstructor = std::function<THolder<IInputStream>(IInputStream*)>;
Expand Down Expand Up @@ -44,7 +45,7 @@ class TCompressionCodecFactory {
TEncoderConstructor Encoder;
};

TDeque<std::string> Strings_;
std::deque<std::string> Strings_;
THashMap<std::string_view, TCodec> Codecs_;
std::vector<std::string_view> BestCodecs_;
};
Expand Down
2 changes: 1 addition & 1 deletion library/cpp/http/io/headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class THttpInputHeader {

/// Контейнер для хранения HTTP-заголовков
class THttpHeaders {
using THeaders = TDeque<THttpInputHeader>;
using THeaders = std::deque<THttpInputHeader>;

public:
using TConstIterator = THeaders::const_iterator;
Expand Down
2 changes: 1 addition & 1 deletion library/cpp/json/writer/json_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace NJson {

public:
typedef THashMap<std::string, TJsonValue> TMapType;
typedef TDeque<TJsonValue> TArray;
typedef std::deque<TJsonValue> TArray;

TJsonValue() noexcept = default;
TJsonValue(EJsonValueType type);
Expand Down
2 changes: 1 addition & 1 deletion library/cpp/resource/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace {
return D_.at(idx).first;
}

typedef TDeque<TDescriptor> TDescriptors;
typedef std::deque<TDescriptor> TDescriptors;
TDescriptors D_;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ Y_UNIT_TEST_SUITE(TestSerializedEnum) {
const std::vector<ETestEnum> typedValues = {ETestEnum::One, ETestEnum::Two, ETestEnum::Three, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Eleven, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Zero, ETestEnum::Two};
UNIT_ASSERT_EQUAL(typedValues, view.Materialize());

const TDeque<ETestEnum> typedValuesDeque{typedValues.begin(), typedValues.end()};
UNIT_ASSERT_EQUAL(typedValuesDeque, view.Materialize<TDeque>());
const std::deque<ETestEnum> typedValuesDeque{typedValues.begin(), typedValues.end()};
UNIT_ASSERT_EQUAL(typedValuesDeque, view.Materialize<std::deque>());
}

Y_UNIT_TEST(MappedDictView) {
Expand Down
4 changes: 2 additions & 2 deletions util/generic/deque.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <memory>
#include <initializer_list>

template <class T, class A>
/*template <class T, class A>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если кроме деки тут ничего не осталось, нужно удалить файл

class TDeque: public std::deque<T, TReboundAllocator<A, T>> {
using TBase = std::deque<T, TReboundAllocator<A, T>>;

Expand All @@ -22,4 +22,4 @@ class TDeque: public std::deque<T, TReboundAllocator<A, T>> {
inline explicit operator bool() const noexcept {
return !this->empty();
}
};
};*/
24 changes: 12 additions & 12 deletions util/generic/deque_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TDequeTest: public TTestBase {
UNIT_TEST_SUITE_REGISTRATION(TDequeTest);

void TDequeTest::TestConstructorsAndAssignments() {
using container = TDeque<int>;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тесты для STL деки не нужны

using container = std::deque<int>;

container c1;
c1.push_back(100);
Expand Down Expand Up @@ -66,7 +66,7 @@ void TDequeTest::TestConstructorsAndAssignments() {
}

void TDequeTest::TestDeque1() {
TDeque<int> d;
std::deque<int> d;
UNIT_ASSERT(!d);

d.push_back(4);
Expand All @@ -89,8 +89,8 @@ void TDequeTest::TestDeque1() {
UNIT_ASSERT(d[2] == 25);

//Some compile time tests:
TDeque<int>::iterator dit = d.begin();
TDeque<int>::const_iterator cdit(d.begin());
std::deque<int>::iterator dit = d.begin();
std::deque<int>::const_iterator cdit(d.begin());

UNIT_ASSERT((dit - cdit) == 0);
UNIT_ASSERT((cdit - dit) == 0);
Expand All @@ -100,14 +100,14 @@ void TDequeTest::TestDeque1() {
}

void TDequeTest::TestInsert() {
TDeque<int> d;
std::deque<int> d;
d.push_back(0);
d.push_back(1);
d.push_back(2);

UNIT_ASSERT(d.size() == 3);

TDeque<int>::iterator dit;
std::deque<int>::iterator dit;

//Insertion before begin:
dit = d.insert(d.begin(), 3);
Expand Down Expand Up @@ -177,8 +177,8 @@ void TDequeTest::TestInsert() {
}

void TDequeTest::TestAt() {
TDeque<int> d;
TDeque<int> const& cd = d;
std::deque<int> d;
std::deque<int> const& cd = d;

d.push_back(10);
UNIT_ASSERT(d.at(0) == 10);
Expand All @@ -189,12 +189,12 @@ void TDequeTest::TestAt() {

void TDequeTest::TestAutoRef() {
int i;
TDeque<int> ref;
std::deque<int> ref;
for (i = 0; i < 5; ++i) {
ref.push_back(i);
}

TDeque<TDeque<int>> d_d_int(1, ref);
std::deque<std::deque<int>> d_d_int(1, ref);
d_d_int.push_back(d_d_int[0]);
d_d_int.push_back(ref);
d_d_int.push_back(d_d_int[0]);
Expand All @@ -207,7 +207,7 @@ void TDequeTest::TestAutoRef() {
}

void TDequeTest::TestErase() {
TDeque<int> dint;
std::deque<int> dint;
dint.push_back(3);
dint.push_front(2);
dint.push_back(4);
Expand All @@ -216,7 +216,7 @@ void TDequeTest::TestErase() {
dint.push_front(0);
dint.push_back(6);

TDeque<int>::iterator it(dint.begin() + 1);
std::deque<int>::iterator it(dint.begin() + 1);
UNIT_ASSERT(*it == 1);

dint.erase(dint.begin());
Expand Down
7 changes: 4 additions & 3 deletions util/generic/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <iosfwd>
#include <vector>
#include <deque>

//misc
class TBuffer;
Expand Down Expand Up @@ -36,8 +37,8 @@ template <class TValue, class TCmp>
class TRbTree;

//containers
template <class T, class A = std::allocator<T>>
class TDeque;
//template <class T, class A = std::allocator<T>>
//class TDeque;

template <class Key, class T, class HashFcn = THash<Key>, class EqualKey = TEqualTo<Key>, class Alloc = std::allocator<Key>>
class THashMap;
Expand All @@ -57,7 +58,7 @@ class TSet;
template <class K, class L = TLess<K>, class A = std::allocator<K>>
class TMultiSet;

template <class T, class S = TDeque<T>>
template <class T, class S = std::deque<T>>
class TStack;

template <size_t BitCount, typename TChunkType = ui64>
Expand Down
2 changes: 1 addition & 1 deletion util/system/atexit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace {
private:
TAdaptiveLock Lock_;
std::atomic<bool> FinishStarted_;
TDeque<TFunc> Store_;
std::deque<TFunc> Store_;
std::priority_queue<TFunc*, std::vector<TFunc*>, TCmp> Items_;
};

Expand Down
2 changes: 1 addition & 1 deletion util/system/context_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Y_UNIT_TEST_SUITE(TestContext) {
char Buf[1000000];
};

static TDeque<TW> w;
static std::deque<TW> w;

auto& tw = w.emplace_back(&f);

Expand Down
4 changes: 0 additions & 4 deletions util/ysaveload.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,6 @@ template <class TChar>
class TSerializer<std::basic_string<TChar>>: public TVectorSerializer<std::basic_string<TChar>> {
};

template <class T, class A>
class TSerializer<TDeque<T, A>>: public TVectorSerializer<TDeque<T, A>> {
};

template <class T, class A>
class TSerializer<std::deque<T, A>>: public TVectorSerializer<std::deque<T, A>> {
};
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/yql/public/issue/yql_issue_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ using namespace NIssue::NProto;
template<typename TIssueMessage>
TIssue IssueFromMessage(const TIssueMessage& issueMessage) {
TIssue topIssue;
TDeque<std::pair<TIssue*, const TIssueMessage*>> queue;
std::deque<std::pair<TIssue*, const TIssueMessage*>> queue;
queue.push_front(std::make_pair(&topIssue, &issueMessage));
while (!queue.empty()) {
TIssue& issue = *queue.back().first;
Expand Down Expand Up @@ -58,7 +58,7 @@ void IssuesFromMessage(const ::google::protobuf::RepeatedPtrField<TIssueMessage>

template<typename TIssueMessage>
void IssueToMessage(const TIssue& topIssue, TIssueMessage* issueMessage) {
TDeque<std::pair<const TIssue*, TIssueMessage*>> queue;
std::deque<std::pair<const TIssue*, TIssueMessage*>> queue;
queue.push_front(std::make_pair(&topIssue, issueMessage));
while (!queue.empty()) {
const TIssue& issue = *queue.back().first;
Expand Down