-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99d530f
commit 96abd52
Showing
11 changed files
with
100 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "positive_integer.h" | ||
#include <ydb/library/actors/core/log.h> | ||
|
||
namespace NKikimr { | ||
|
||
TPositiveControlInteger::TPositiveControlInteger(const i64 value) | ||
: Value(value) { | ||
AFL_VERIFY(0 <= value); | ||
} | ||
|
||
ui64 TPositiveControlInteger::Add(const ui64 value) { | ||
Value += value; | ||
return Value; | ||
} | ||
|
||
ui64 TPositiveControlInteger::Sub(const ui64 value) { | ||
if (value <= Value) { | ||
Value -= value; | ||
} else { | ||
AFL_VERIFY(false)("base", Value)("delta", value); | ||
} | ||
return Value; | ||
} | ||
|
||
ui64 TPositiveControlInteger::GetDec() const { | ||
if (Value) { | ||
return Value - 1; | ||
} else { | ||
AFL_VERIFY(false); | ||
} | ||
return 0; | ||
} | ||
|
||
ui64 TPositiveControlInteger::Val() const { | ||
return Value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
#include <util/system/types.h> | ||
|
||
namespace NKikimr { | ||
|
||
class TPositiveControlInteger { | ||
private: | ||
ui64 Value = 0; | ||
public: | ||
TPositiveControlInteger() = default; | ||
TPositiveControlInteger(const ui64 value) | ||
: Value(value) { | ||
|
||
} | ||
TPositiveControlInteger(const i64 value); | ||
ui64 Add(const ui64 value); | ||
ui64 Sub(const ui64 value); | ||
ui64 Inc() { | ||
return Add(1); | ||
} | ||
ui64 Dec() { | ||
return Sub(1); | ||
} | ||
ui64 GetDec() const; | ||
ui64 Val() const; | ||
bool operator!() const { | ||
return !Value; | ||
} | ||
operator ui64() const { | ||
return Value; | ||
} | ||
ui64 operator++() { | ||
return Inc(); | ||
} | ||
ui64 operator--() { | ||
return Dec(); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ PEERDIR( | |
SRCS( | ||
accessor.cpp | ||
validator.cpp | ||
positive_integer.cpp | ||
) | ||
|
||
END() | ||
|