Skip to content

Commit

Permalink
Add huffman
Browse files Browse the repository at this point in the history
  • Loading branch information
wjr-z committed Oct 17, 2024
1 parent d150bf2 commit 5277909
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 74 deletions.
28 changes: 17 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ option(WJR_DISABLE_EXCEPTIONS "Disable exceptions" ON)
option(WJR_DISABLE_CXX_20 "Disable C++ 20 even if it's supported." ON)

if (DEFINED WJR_DEBUG_LEVEL AND (NOT DEFINED WJR_DEBUG_LEVEL_DEBUG))
set(WJR_DEBUG_LEVEL_DEBUG_TMP ${WJR_DEBUG_LEVEL})
set(WJR_DEBUG_LEVEL_DEBUG ${WJR_DEBUG_LEVEL})
endif()

if (DEFINED WJR_DEBUG_LEVEL AND (NOT DEFINED WJR_DEBUG_LEVEL_RELEASE))
set(WJR_DEBUG_LEVEL_RELEASE_TMP ${WJR_DEBUG_LEVEL})
set(WJR_DEBUG_LEVEL_RELEASE ${WJR_DEBUG_LEVEL})
endif()

if (NOT DEFINED WJR_DEBUG_LEVEL_DEBUG)
set(WJR_DEBUG_LEVEL_DEBUG_TMP 3)
set(WJR_DEBUG_LEVEL_DEBUG 3)
else()
set(WJR_DEBUG_LEVEL_DEBUG_TMP ${WJR_DEBUG_LEVEL_DEBUG})
set(WJR_DEBUG_LEVEL_DEBUG ${WJR_DEBUG_LEVEL_DEBUG})
endif()

if (NOT DEFINED WJR_DEBUG_LEVEL_RELEASE)
set(WJR_DEBUG_LEVEL_RELEASE_TMP 0)
set(WJR_DEBUG_LEVEL_RELEASE 0)
else()
set(WJR_DEBUG_LEVEL_RELEASE_TMP ${WJR_DEBUG_LEVEL_RELEASE})
set(WJR_DEBUG_LEVEL_RELEASE ${WJR_DEBUG_LEVEL_RELEASE})
endif()

set(WJR_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
Expand Down Expand Up @@ -111,8 +111,8 @@ if(MSVC)

list(APPEND WJR_CXX_FLAGS /W3 /Zc:preprocessor /Zc:lambda /EHsc)

list(APPEND WJR_CXX_FLAGS_DEBUG /DWJR_DEBUG_LEVEL=${WJR_DEBUG_LEVEL_DEBUG_TMP})
list(APPEND WJR_CXX_FLAGS_RELEASE /DWJR_DEBUG_LEVEL=${WJR_DEBUG_LEVEL_RELEASE_TMP})
list(APPEND WJR_CXX_FLAGS_DEBUG /DWJR_DEBUG_LEVEL=${WJR_DEBUG_LEVEL_DEBUG})
list(APPEND WJR_CXX_FLAGS_RELEASE /DWJR_DEBUG_LEVEL=${WJR_DEBUG_LEVEL_RELEASE})

if (WIN32)
list(APPEND WJR_CXX_LINKER_FLAGS /lsynchronization)
Expand All @@ -124,8 +124,8 @@ else()

list(APPEND WJR_CXX_FLAGS -march=native -Wall -Wextra -Wshadow -Wformat=2 -Wunused)

list(APPEND WJR_CXX_FLAGS_DEBUG -DWJR_DEBUG_LEVEL=${WJR_DEBUG_LEVEL_DEBUG_TMP})
list(APPEND WJR_CXX_FLAGS_RELEASE -DWJR_DEBUG_LEVEL=${WJR_DEBUG_LEVEL_RELEASE_TMP})
list(APPEND WJR_CXX_FLAGS_DEBUG -DWJR_DEBUG_LEVEL=${WJR_DEBUG_LEVEL_DEBUG})
list(APPEND WJR_CXX_FLAGS_RELEASE -DWJR_DEBUG_LEVEL=${WJR_DEBUG_LEVEL_RELEASE})

if (WIN32)
list(APPEND WJR_CXX_LINKER_FLAGS -lsynchronization)
Expand Down Expand Up @@ -165,6 +165,12 @@ if(WJR_DISABLE_EXCEPTIONS)
)
endif()

if(WJR_LIGHT_ASSERT)
target_compile_definitions(wjr
PUBLIC $<$<COMPILE_LANGUAGE:CXX>: -DWJR_LIGHT_ASSERT >
)
endif()

if (WJR_USE_CXX_20)
set(WJR_ATOMIC_LIBS)
else()
Expand All @@ -189,5 +195,5 @@ target_link_libraries(wjr
${WJR_ATOMIC_LIBS}
)

set(WJR_PCH PUBLIC ${WJR_INCLUDE_DIR}/wjr/assert.hpp ${WJR_INCLUDE_DIR}/wjr/biginteger.hpp)
set(WJR_PCH PUBLIC ${WJR_INCLUDE_DIR}/wjr/type_traits.hpp ${WJR_INCLUDE_DIR}/wjr/assert.hpp)
target_precompile_headers(wjr PUBLIC ${WJR_PCH})
20 changes: 10 additions & 10 deletions include/wjr/biginteger/biginteger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,35 +262,35 @@ namespace biginteger_detail {

/// @private
template <typename S>
bool __equal_pointer(const basic_biginteger<S> *lhs,
const basic_biginteger<S> *rhs) noexcept {
WJR_CONST bool __equal_pointer(const basic_biginteger<S> *lhs,
const basic_biginteger<S> *rhs) noexcept {
return lhs == rhs;
}

/// @private
template <typename S0, typename S1>
bool __equal_pointer(const basic_biginteger<S0> *,
const basic_biginteger<S1> *) noexcept {
WJR_CONST bool __equal_pointer(const basic_biginteger<S0> *,
const basic_biginteger<S1> *) noexcept {
return false;
}

/// @private
template <typename S>
bool __equal_pointer(const basic_biginteger<S> *lhs,
const biginteger_data *rhs) noexcept {
WJR_PURE bool __equal_pointer(const basic_biginteger<S> *lhs,
const biginteger_data *rhs) noexcept {
return lhs->__get_data() == rhs;
}

/// @private
template <typename S>
bool __equal_pointer(const biginteger_data *lhs,
const basic_biginteger<S> *rhs) noexcept {
WJR_PURE bool __equal_pointer(const biginteger_data *lhs,
const basic_biginteger<S> *rhs) noexcept {
return lhs == rhs->__get_data();
}

/// @private
inline bool __equal_pointer(const biginteger_data *lhs,
const biginteger_data *rhs) noexcept {
WJR_CONST inline bool __equal_pointer(const biginteger_data *lhs,
const biginteger_data *rhs) noexcept {
return lhs == rhs;
}

Expand Down
File renamed without changes.
6 changes: 0 additions & 6 deletions include/wjr/concurrency/mutex-config.hpp

This file was deleted.

4 changes: 0 additions & 4 deletions include/wjr/concurrency/scheduler.hpp

This file was deleted.

9 changes: 7 additions & 2 deletions include/wjr/container/constant_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <array>
#include <string_view>

#include <wjr/type_traits.hpp>
#include <wjr/algorithm.hpp>

namespace wjr {

Expand All @@ -15,12 +15,17 @@ class string_map {
public:
using key_type = std::string_view;

constexpr string_map(const key_type (&keys)[KeySize]) noexcept : m_keys(keys) {}
constexpr string_map(const key_type (&keys)[KeySize]) noexcept : m_keys(keys) {
constant::sort(m_keys.begin(), m_keys.end());
}

private:
std::array<key_type, KeySize> m_keys;
};

template <size_t KeySize>
string_map(const std::string_view (&keys)[KeySize]) -> string_map<KeySize>;

} // namespace constant

} // namespace wjr
Expand Down
1 change: 0 additions & 1 deletion include/wjr/container/container_fn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace wjr {


/**
* @class container_fn<Alloc>
* @brief The same characteristics and behavior of all allocator containers
Expand Down
Loading

0 comments on commit 5277909

Please sign in to comment.