-
Notifications
You must be signed in to change notification settings - Fork 219
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
33c4da9
commit e4b2cf4
Showing
14 changed files
with
587 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#ifndef CONCURRENCPP_DLIST_H | ||
#define CONCURRENCPP_DLIST_H | ||
|
||
#include "concurrencpp/platform_defs.h" | ||
|
||
#include <cassert> | ||
|
||
namespace concurrencpp::details { | ||
template<class node_type> | ||
class dlist { | ||
|
||
private: | ||
node_type* m_head = nullptr; | ||
|
||
public: | ||
void push_front(node_type& new_node) noexcept { | ||
assert(new_node.next == nullptr); | ||
assert(new_node.prev == nullptr); | ||
|
||
if (m_head != nullptr) { | ||
m_head->prev = &new_node; | ||
new_node.next = m_head; | ||
} | ||
|
||
m_head = &new_node; | ||
} | ||
|
||
void remove_node(node_type& old_node) noexcept { | ||
assert(m_head != nullptr); | ||
assert(old_node.prev != nullptr || old_node.next != nullptr); | ||
|
||
if (old_node.prev != nullptr) { | ||
old_node.prev->next = old_node.next; | ||
} else { | ||
m_head = old_node.next; | ||
} | ||
|
||
if (old_node.next != nullptr) { | ||
old_node.next->prev = old_node.prev; | ||
} | ||
} | ||
|
||
bool empty() const noexcept { | ||
return m_head != nullptr; | ||
} | ||
|
||
template<class functor_type> | ||
void for_each(functor_type f) { | ||
auto cursor = m_head; | ||
while (cursor != nullptr) { | ||
const bool should_continue_iteration = f(*cursor); | ||
if (!should_continue_iteration) { | ||
return; | ||
} | ||
|
||
cursor = cursor->next; | ||
} | ||
} | ||
}; | ||
} // namespace concurrencpp::details | ||
|
||
#endif |
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,15 @@ | ||
#ifndef CONCURRENCPP_MATH_H | ||
#define CONCURRENCPP_MATH_H | ||
|
||
#include "concurrencpp/platform_defs.h" | ||
|
||
#include <cstddef> | ||
|
||
namespace concurrencpp::details { | ||
struct CRCPP_API math_helper { | ||
static bool is_prime(size_t n) noexcept; | ||
static size_t next_prime(size_t n) noexcept; | ||
}; | ||
} // namespace concurrencpp::details | ||
|
||
#endif |
Oops, something went wrong.