Skip to content

Commit

Permalink
Add a new data member max to integer_set
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Mar 24, 2024
1 parent a9ea532 commit a891dda
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ string(JOIN " " AGGRESSIVE_OPTIMIZATION_OPTIONS
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_DEBUG "-Og -gdwarf-4") # NOTE: The `-gdwarf-4` option is set due to the following issues with Clang 14 and Valgrind versions below 3.20: https://bugzilla.mozilla.org/show_bug.cgi?id=1758782
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${AGGRESSIVE_OPTIMIZATION_OPTIONS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gdwarf-4 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ${AGGRESSIVE_OPTIMIZATION_OPTIONS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -gdwarf-4")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -pipe")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Procedures for each standard are provided by the following R7RS-style libraries:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cd build
make package
sudo apt install build/meevax_0.5.156_amd64.deb
sudo apt install build/meevax_0.5.157_amd64.deb
```

or
Expand Down Expand Up @@ -123,9 +123,9 @@ sudo rm -rf /usr/local/share/meevax

| Target Name | Description
|-------------|-------------
| `all` | Build shared-library `libmeevax.0.5.156.so` and executable `meevax`
| `all` | Build shared-library `libmeevax.0.5.157.so` and executable `meevax`
| `test` | Test executable `meevax`
| `package` | Generate debian package `meevax_0.5.156_amd64.deb`
| `package` | Generate debian package `meevax_0.5.157_amd64.deb`
| `install` | Copy files into `/usr/local` directly

## Usage
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.156
0.5.157
7 changes: 5 additions & 2 deletions include/meevax/memory/collector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ inline namespace memory
{
using base_pointer = nan_boxing_pointer<Top, Ts...>;

mutator(std::nullptr_t = nullptr)
mutator(std::nullptr_t = nullptr) noexcept
{}

mutator(mutator const& other)
Expand Down Expand Up @@ -191,7 +191,10 @@ inline namespace memory

~mutator()
{
mutators.erase(this);
if (not cleared)
{
mutators.erase(this);
}
}

auto operator =(mutator const& other) -> auto &
Expand Down
11 changes: 10 additions & 1 deletion include/meevax/memory/integer_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ inline namespace memory

subset * data[N] = {};

std::size_t max = 0;

struct const_iterator : public std::iterator<std::bidirectional_iterator_tag, T>
{
subset const* const* data = nullptr;

std::size_t max = 0;

std::size_t i = std::numeric_limits<std::size_t>::max();

typename subset::const_iterator iter;
Expand All @@ -58,6 +62,7 @@ inline namespace memory

explicit const_iterator(integer_set const* container, std::size_t i, std::uintptr_t j = 0) noexcept
: data { container->data }
, max { container->max }
, i { i }
{
assert(i <= N);
Expand All @@ -66,6 +71,7 @@ inline namespace memory

explicit const_iterator(integer_set const* container) noexcept
: data { container->data }
, max { container->max }
, i { N }
{
decrement_unless_truthy();
Expand All @@ -82,13 +88,15 @@ inline namespace memory
{
return;
}
else for (++i; good(); ++i)
else for (++i; i <= max; ++i)
{
if (data[i] and (iter = data[i]->lower_bound(0)).good())
{
return;
}
}

i = N;
}

iter = {};
Expand Down Expand Up @@ -209,6 +217,7 @@ inline namespace memory
}
else
{
max = std::max(max, i);
data[i] = new subset();
data[i]->insert(j);
}
Expand Down

0 comments on commit a891dda

Please sign in to comment.