Skip to content

Commit

Permalink
Merge pull request #3 from coopsdev/circular-buffer
Browse files Browse the repository at this point in the history
refactor to circular buffer -> less overhead
  • Loading branch information
cooperlarson authored Aug 2, 2024
2 parents 6869d19 + 56c754b commit 1cb2242
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 206 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
types: [ closed ]
branches:
- main
- master

jobs:
package-and-upload:
Expand Down Expand Up @@ -36,8 +36,8 @@ jobs:
- name: Package
run: |
cd /home/gh-runner/actions-runner/_work/TSP/TSP
conan create . -pr:a vps-release --test-folder="" --build=missing
cd /home/gh-runner/actions-runner/_work/BoundedPriorityDeque/BoundedPriorityDeque
conan create . -pr:a vps-release --build=missing
- name: Upload Packages to Artifactory
run: |
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: C++ CI Build

on:
pull_request:
branches: [main]
branches: [master]

jobs:
build-and-test:
Expand Down Expand Up @@ -37,14 +37,12 @@ jobs:
- name: Compile and Link
run: |
conan build . -pr:a vps-release --build=missing
conan build . -pr:a vps-debug --build=missing
- name: Show ccache stats after build
run: ccache -s

- name: Run Tests
env:
PATH_TO_TSP_TEST_DATA: /home/gh-runner/actions-runner/_work/TSP/TSP/resources/testData
run: |
echo "Using test data path $PATH_TO_TSP_TEST_DATA"
./build/meson/runTests
cd /home/gh-runner/actions-runner/_work/BoundedPriorityDeque/BoundedPriorityDeque
./build/meson/testDeque
6 changes: 3 additions & 3 deletions .github/workflows/push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: C++ CI Push Main

on:
push:
branches: [main]
branches: [master]

jobs:
build-package:
Expand Down Expand Up @@ -46,8 +46,8 @@ jobs:

- name: Create Package
run: |
cd /home/gh-runner/actions-runner/_work/TSP/TSP
conan create . -pr:a vps-release --test-folder="" --build=missing
cd /home/gh-runner/actions-runner/_work/BoundedPriorityDeque/BoundedPriorityDeque
conan create . -pr:a vps-release --build=missing
- name: Upload Packages to Artifactory
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: C++ CI Release
on:
release:
types: [published] # run on release
branches: [main]
branches: [master]

jobs:
build-package:
Expand Down Expand Up @@ -45,8 +45,8 @@ jobs:
- name: Create Package
run: |
cd /home/gh-runner/actions-runner/_work/
conan create . -pr:a vps-release --test-folder="" --build=missing
/home/gh-runner/actions-runner/_work/BoundedPriorityDeque/BoundedPriorityDeque
conan create . -pr:a vps-release --build=missing
- name: Upload Packages to Artifactory
run: |
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Pkg(ConanFile):
name = "bpd"
version = "0.2.0"
version = "0.2.1"
license = "MIT"
author = "Cooper Larson | [email protected]"
url = ""
Expand Down
8 changes: 2 additions & 6 deletions include/BoundedMaxPriorityDeque.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@

template<typename K, typename V>
class BoundedMaxPriorityDeque : public BoundedPriorityDequeBase<K, V> {
using Node = BoundedPriorityDequeBase<K, V>::Node;

protected:
[[nodiscard]] bool compareElements(K a, K b) const override { return a > b; }
[[nodiscard]] bool compare(K a, K b) const override { return a > b; }

public:
explicit BoundedMaxPriorityDeque(unsigned int capacity = 0) :
BoundedPriorityDequeBase<K, V>(
[](const Node* a, const Node* b) { return a->_data.first > b->_data.first; }, capacity) {}
explicit BoundedMaxPriorityDeque(unsigned int capacity = 0) : BoundedPriorityDequeBase<K, V>(capacity) {}

};

Expand Down
8 changes: 2 additions & 6 deletions include/BoundedMinPriorityDeque.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@

template<typename K, typename V>
class BoundedMinPriorityDeque : public BoundedPriorityDequeBase<K, V> {
using Node = BoundedPriorityDequeBase<K, V>::Node;

protected:
[[nodiscard]] bool compareElements(K a, K b) const override { return a < b; }
[[nodiscard]] bool compare(K a, K b) const override { return a < b; }

public:
explicit BoundedMinPriorityDeque(unsigned int capacity = 0) :
BoundedPriorityDequeBase<K, V>(
[](const Node* a, const Node* b) { return a->_data.first < b->_data.first; }, capacity) {}
explicit BoundedMinPriorityDeque(unsigned int capacity = 0) : BoundedPriorityDequeBase<K, V>(capacity) {}

};

Expand Down
8 changes: 2 additions & 6 deletions include/BoundedPriorityDeque.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@

template<typename K, typename V, typename Comparator = std::less<K>>
class BoundedPriorityDeque : public BoundedPriorityDequeBase<K, V> {
using Node = BoundedPriorityDequeBase<K, V>::Node;

protected:
Comparator comparator;

[[nodiscard]] bool compareElements(K a, K b) const override { return comparator(a, b); }
[[nodiscard]] bool compare(K a, K b) const override { return comparator(a, b); }

public:
explicit BoundedPriorityDeque(unsigned int capacity = 0, Comparator comp = Comparator()) :
BoundedPriorityDequeBase<K, V>(
[](const Node* a, const Node* b) { return Comparator()(a->_data.first, b->_data.first); },
capacity), comparator(comp) {}
BoundedPriorityDequeBase<K, V>(capacity), comparator(comp) {}

};

Expand Down
Loading

0 comments on commit 1cb2242

Please sign in to comment.