Navigation Menu

Skip to content

Commit

Permalink
Rename grn::dat::UINT*_MAX to grn::dat::MAX_UINT*.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yata committed Aug 31, 2012
1 parent a2af5ca commit d5deea5
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 80 deletions.
2 changes: 1 addition & 1 deletion lib/dat/cursor-factory.hpp
Expand Up @@ -31,7 +31,7 @@ class GRN_DAT_API CursorFactory {
const void *min_ptr, UInt32 min_length,
const void *max_ptr, UInt32 max_length,
UInt32 offset = 0,
UInt32 limit = UINT32_MAX,
UInt32 limit = MAX_UINT32,
UInt32 flags = 0);

private:
Expand Down
19 changes: 4 additions & 15 deletions lib/dat/dat.hpp
Expand Up @@ -57,21 +57,10 @@ typedef ::uint32_t UInt32;
typedef ::uint64_t UInt64;
#endif // _MSC_VER

#ifndef UINT8_MAX
const UInt8 UINT8_MAX = static_cast<UInt8>(0xFFU);
#endif // UINT8_MAX

#ifndef UINT16_MAX
const UInt16 UINT16_MAX = static_cast<UInt16>(0xFFFFU);
#endif // UINT16_MAX

#ifndef UINT32_MAX
const UInt32 UINT32_MAX = static_cast<UInt32>(0xFFFFFFFFU);
#endif // UINT32_MAX

#ifndef UINT64_MAX
const UInt64 UINT64_MAX = static_cast<UInt64>(0xFFFFFFFFFFFFFFFFULL);
#endif // UINT64_MAX
const UInt8 MAX_UINT8 = static_cast<UInt8>(0xFFU);
const UInt16 MAX_UINT16 = static_cast<UInt16>(0xFFFFU);
const UInt32 MAX_UINT32 = static_cast<UInt32>(0xFFFFFFFFU);
const UInt64 MAX_UINT64 = static_cast<UInt64>(0xFFFFFFFFFFFFFFFFULL);

// If a key is a prefix of another key, such a key is associated with a special
// terminal node which has TERMINAL_LABEL.
Expand Down
2 changes: 1 addition & 1 deletion lib/dat/id-cursor.cpp
Expand Up @@ -27,7 +27,7 @@ namespace dat {
IdCursor::IdCursor()
: trie_(NULL),
offset_(0),
limit_(UINT32_MAX),
limit_(MAX_UINT32),
flags_(ID_RANGE_CURSOR),
cur_(INVALID_KEY_ID),
end_(INVALID_KEY_ID) {}
Expand Down
4 changes: 2 additions & 2 deletions lib/dat/id-cursor.hpp
Expand Up @@ -34,14 +34,14 @@ class GRN_DAT_API IdCursor : public Cursor {
const String &min_str,
const String &max_str,
UInt32 offset = 0,
UInt32 limit = UINT32_MAX,
UInt32 limit = MAX_UINT32,
UInt32 flags = 0);

void open(const Trie &trie,
UInt32 min_id,
UInt32 max_id,
UInt32 offset = 0,
UInt32 limit = UINT32_MAX,
UInt32 limit = MAX_UINT32,
UInt32 flags = 0);

void close();
Expand Down
6 changes: 3 additions & 3 deletions lib/dat/key-cursor.cpp
Expand Up @@ -28,7 +28,7 @@ namespace dat {
KeyCursor::KeyCursor()
: trie_(NULL),
offset_(0),
limit_(UINT32_MAX),
limit_(MAX_UINT32),
flags_(KEY_RANGE_CURSOR),
buf_(),
count_(0),
Expand Down Expand Up @@ -112,8 +112,8 @@ UInt32 KeyCursor::fix_flags(UInt32 flags) const {
}

void KeyCursor::init(const String &min_str, const String &max_str) {
if (offset_ > (UINT32_MAX - limit_)) {
max_count_ = UINT32_MAX;
if (offset_ > (MAX_UINT32 - limit_)) {
max_count_ = MAX_UINT32;
} else {
max_count_ = offset_ + limit_;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/dat/key-cursor.hpp
Expand Up @@ -35,7 +35,7 @@ class GRN_DAT_API KeyCursor : public Cursor {
const String &min_str,
const String &max_str,
UInt32 offset = 0,
UInt32 limit = UINT32_MAX,
UInt32 limit = MAX_UINT32,
UInt32 flags = 0);

void close();
Expand Down
4 changes: 2 additions & 2 deletions lib/dat/predictive-cursor.cpp
Expand Up @@ -28,7 +28,7 @@ namespace dat {
PredictiveCursor::PredictiveCursor()
: trie_(NULL),
offset_(0),
limit_(UINT32_MAX),
limit_(MAX_UINT32),
flags_(PREDICTIVE_CURSOR),
buf_(),
cur_(0),
Expand Down Expand Up @@ -107,7 +107,7 @@ void PredictiveCursor::init(const String &str) {
if ((flags_ & EXCEPT_EXACT_MATCH) == EXCEPT_EXACT_MATCH) {
++min_length_;
}
end_ = (offset_ > (UINT32_MAX - limit_)) ? UINT32_MAX : (offset_ + limit_);
end_ = (offset_ > (MAX_UINT32 - limit_)) ? MAX_UINT32 : (offset_ + limit_);

UInt32 node_id = ROOT_NODE_ID;
for (UInt32 i = 0; i < str.length(); ++i) {
Expand Down
2 changes: 1 addition & 1 deletion lib/dat/predictive-cursor.hpp
Expand Up @@ -34,7 +34,7 @@ class GRN_DAT_API PredictiveCursor : public Cursor {
void open(const Trie &trie,
const String &str,
UInt32 offset = 0,
UInt32 limit = UINT32_MAX,
UInt32 limit = MAX_UINT32,
UInt32 flags = 0);

void close();
Expand Down
2 changes: 1 addition & 1 deletion lib/dat/prefix-cursor.cpp
Expand Up @@ -27,7 +27,7 @@ namespace dat {
PrefixCursor::PrefixCursor()
: trie_(NULL),
offset_(0),
limit_(UINT32_MAX),
limit_(MAX_UINT32),
flags_(PREFIX_CURSOR),
buf_(),
cur_(0),
Expand Down
2 changes: 1 addition & 1 deletion lib/dat/prefix-cursor.hpp
Expand Up @@ -35,7 +35,7 @@ class GRN_DAT_API PrefixCursor : public Cursor {
const String &str,
UInt32 min_length = 0,
UInt32 offset = 0,
UInt32 limit = UINT32_MAX,
UInt32 limit = MAX_UINT32,
UInt32 flags = 0);

void close();
Expand Down
4 changes: 2 additions & 2 deletions lib/dat/vector.hpp
Expand Up @@ -128,10 +128,10 @@ class Vector {
if (new_capacity <= capacity()) {
return;
} else if ((new_capacity / 2) < capacity()) {
if (capacity() < (UINT32_MAX / 2)) {
if (capacity() < (MAX_UINT32 / 2)) {
new_capacity = capacity() * 2;
} else {
new_capacity = UINT32_MAX;
new_capacity = MAX_UINT32;
}
}

Expand Down
14 changes: 7 additions & 7 deletions test/unit/core/dat/test-id-cursor.cpp
Expand Up @@ -242,7 +242,7 @@ namespace test_dat_id_cursor

grn::dat::IdCursor cursor;

cursor.open(trie, 3, 6, 0, grn::dat::UINT32_MAX);
cursor.open(trie, 3, 6, 0, grn::dat::MAX_UINT32);
for (grn::dat::UInt32 i = 3; i <= 6; ++i) {
const grn::dat::Key &key = cursor.next();
cppcut_assert_equal(true, key.is_valid());
Expand Down Expand Up @@ -280,15 +280,15 @@ namespace test_dat_id_cursor
grn::dat::IdCursor cursor;

cursor.open(trie, grn::dat::INVALID_KEY_ID, grn::dat::INVALID_KEY_ID,
0, grn::dat::UINT32_MAX, grn::dat::ASCENDING_CURSOR);
0, grn::dat::MAX_UINT32, grn::dat::ASCENDING_CURSOR);
for (grn::dat::UInt32 i = trie.min_key_id(); i <= trie.max_key_id(); ++i) {
const grn::dat::Key &key = cursor.next();
cppcut_assert_equal(true, key.is_valid());
cppcut_assert_equal(i, key.id());
}
cppcut_assert_equal(false, cursor.next().is_valid());

cursor.open(trie, 2, 7, 0, grn::dat::UINT32_MAX,
cursor.open(trie, 2, 7, 0, grn::dat::MAX_UINT32,
grn::dat::ASCENDING_CURSOR);
for (grn::dat::UInt32 i = 2; i <= 7; ++i) {
const grn::dat::Key &key = cursor.next();
Expand All @@ -314,15 +314,15 @@ namespace test_dat_id_cursor
grn::dat::IdCursor cursor;

cursor.open(trie, grn::dat::INVALID_KEY_ID, grn::dat::INVALID_KEY_ID,
0, grn::dat::UINT32_MAX, grn::dat::DESCENDING_CURSOR);
0, grn::dat::MAX_UINT32, grn::dat::DESCENDING_CURSOR);
for (grn::dat::UInt32 i = trie.max_key_id(); i >= trie.min_key_id(); --i) {
const grn::dat::Key &key = cursor.next();
cppcut_assert_equal(true, key.is_valid());
cppcut_assert_equal(i, key.id());
}
cppcut_assert_equal(false, cursor.next().is_valid());

cursor.open(trie, 2, 7, 0, grn::dat::UINT32_MAX,
cursor.open(trie, 2, 7, 0, grn::dat::MAX_UINT32,
grn::dat::DESCENDING_CURSOR);
for (grn::dat::UInt32 i = 7; i >= 2; --i) {
const grn::dat::Key &key = cursor.next();
Expand All @@ -348,7 +348,7 @@ namespace test_dat_id_cursor
grn::dat::IdCursor cursor;

cursor.open(trie, grn::dat::INVALID_KEY_ID, grn::dat::INVALID_KEY_ID,
0, grn::dat::UINT32_MAX,
0, grn::dat::MAX_UINT32,
grn::dat::EXCEPT_LOWER_BOUND | grn::dat::EXCEPT_UPPER_BOUND);
for (grn::dat::UInt32 i = trie.min_key_id(); i <= trie.max_key_id(); ++i) {
const grn::dat::Key &key = cursor.next();
Expand All @@ -358,7 +358,7 @@ namespace test_dat_id_cursor
cppcut_assert_equal(false, cursor.next().is_valid());

cursor.open(trie, trie.min_key_id(), trie.max_key_id(),
0, grn::dat::UINT32_MAX,
0, grn::dat::MAX_UINT32,
grn::dat::EXCEPT_LOWER_BOUND | grn::dat::EXCEPT_UPPER_BOUND);
for (grn::dat::UInt32 i = trie.min_key_id() + 1;
i <= (trie.max_key_id() - 1); ++i) {
Expand Down
16 changes: 8 additions & 8 deletions test/unit/core/dat/test-key-cursor.cpp
Expand Up @@ -155,7 +155,7 @@ namespace test_dat_key_cursor
grn::dat::KeyCursor cursor;

cursor.open(trie, grn::dat::String("Gnome"), grn::dat::String("Werdna"),
0, grn::dat::UINT32_MAX);
0, grn::dat::MAX_UINT32);
cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
Expand Down Expand Up @@ -187,7 +187,7 @@ namespace test_dat_key_cursor
grn::dat::KeyCursor cursor;

cursor.open(trie, grn::dat::String(), grn::dat::String(),
0, grn::dat::UINT32_MAX, grn::dat::ASCENDING_CURSOR);
0, grn::dat::MAX_UINT32, grn::dat::ASCENDING_CURSOR);
cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
Expand All @@ -198,7 +198,7 @@ namespace test_dat_key_cursor
cppcut_assert_equal(false, cursor.next().is_valid());

cursor.open(trie, grn::dat::String("Elf"), grn::dat::String("Human"),
0, grn::dat::UINT32_MAX, grn::dat::ASCENDING_CURSOR);
0, grn::dat::MAX_UINT32, grn::dat::ASCENDING_CURSOR);
cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
Expand All @@ -220,7 +220,7 @@ namespace test_dat_key_cursor
grn::dat::KeyCursor cursor;

cursor.open(trie, grn::dat::String(), grn::dat::String(),
0, grn::dat::UINT32_MAX, grn::dat::DESCENDING_CURSOR);
0, grn::dat::MAX_UINT32, grn::dat::DESCENDING_CURSOR);
cppcut_assert_equal(grn::dat::UInt32(1), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(2), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
Expand All @@ -231,7 +231,7 @@ namespace test_dat_key_cursor
cppcut_assert_equal(false, cursor.next().is_valid());

cursor.open(trie, grn::dat::String("Elf"), grn::dat::String("Human"),
0, grn::dat::UINT32_MAX, grn::dat::DESCENDING_CURSOR);
0, grn::dat::MAX_UINT32, grn::dat::DESCENDING_CURSOR);
cppcut_assert_equal(grn::dat::UInt32(3), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
Expand All @@ -253,7 +253,7 @@ namespace test_dat_key_cursor
grn::dat::KeyCursor cursor;

cursor.open(trie, grn::dat::String(), grn::dat::String(),
0, grn::dat::UINT32_MAX,
0, grn::dat::MAX_UINT32,
grn::dat::EXCEPT_LOWER_BOUND | grn::dat::EXCEPT_UPPER_BOUND);
cppcut_assert_equal(grn::dat::UInt32(5), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
Expand All @@ -265,7 +265,7 @@ namespace test_dat_key_cursor
cppcut_assert_equal(false, cursor.next().is_valid());

cursor.open(trie, grn::dat::String("Dwarf"), grn::dat::String("Werdna"),
0, grn::dat::UINT32_MAX,
0, grn::dat::MAX_UINT32,
grn::dat::EXCEPT_LOWER_BOUND | grn::dat::EXCEPT_UPPER_BOUND);
cppcut_assert_equal(grn::dat::UInt32(4), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
Expand All @@ -287,7 +287,7 @@ namespace test_dat_key_cursor
cppcut_assert_equal(false, cursor.next().is_valid());

cursor.open(trie, grn::dat::String("Fighter"), grn::dat::String("Samurai"),
0, grn::dat::UINT32_MAX,
0, grn::dat::MAX_UINT32,
grn::dat::EXCEPT_LOWER_BOUND | grn::dat::EXCEPT_UPPER_BOUND);
cppcut_assert_equal(grn::dat::UInt32(6), cursor.next().id());
cppcut_assert_equal(grn::dat::UInt32(7), cursor.next().id());
Expand Down

0 comments on commit d5deea5

Please sign in to comment.