Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/AutoRelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: AutoRelease

on:
push:
branches: [ main, release ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
update-tag:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Get the latest tag
id: get_tag
run: echo "::set-output name=tag::$(git describe --tags --abbrev=0)"
- name: Increment version
id: increment_version
run: echo "::set-output name=version::$(echo ${{ steps.get_tag.outputs.tag }} | awk -F. '{$NF = $NF + 1;} 1' OFS=.)"
- name: Push new tag
uses: EndBug/latest-tag@latest
with:
tag-name: "v${{ steps.increment_version.outputs.version }}"
4 changes: 2 additions & 2 deletions .github/workflows/VStest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: 'recursive' # Ensure submodules are fetched

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
uses: microsoft/setup-msbuild@v2

- name: Restore NuGet packages
working-directory: ${{env.GITHUB_WORKSPACE}}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/msbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: MSBuild
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
branches: [ main, release ]
pull_request:
branches: [ main ]

Expand All @@ -21,12 +21,12 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
uses: microsoft/setup-msbuild@v2

- name: Restore NuGet packages
working-directory: ${{env.GITHUB_WORKSPACE}}
Expand All @@ -39,9 +39,9 @@ jobs:
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}}

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.7
uses: gittools/actions/gitversion/setup@v1.1.1
with:
versionSpec: '5.x'

- name: Determine Version
uses: gittools/actions/gitversion/execute@v0.9.7
uses: gittools/actions/gitversion/execute@v1.1.1
28 changes: 27 additions & 1 deletion C++/C++.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LambdaFunctions", "LambdaFu
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InputOutput", "InputOutput\InputOutput.vcxproj", "{60CD8FE7-EB95-403D-A0E2-5E89188BA387}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Forward", "Forward\Forward.vcxproj", "{1135FA47-DE13-4E20-8EC0-C01BFD96B155}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MoveSemantics", "MoveSemantics\MoveSemantics.vcxproj", "{1135FA47-DE13-4E20-8EC0-C01BFD96B155}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Regex", "Regex\Regex.vcxproj", "{2134645E-A12D-4143-898F-C2D5C9DE5F4F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PyBind", "PyBind", "{9B6D7C1A-6E3F-4F0B-9E9C-0B5C6A8F2E77}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PyBindAiry", "PyBind\PyBindAiry\PyBindAiry.vcxproj", "{33B48397-2D59-4D3F-B18C-BF52CC4A3785}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PyBindGetInteger", "PyBind\PyBindGetInteger\PyBindGetInteger.vcxproj", "{4A519CF2-1985-46E5-B701-A3B48E8DE940}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -51,10 +57,30 @@ Global
{2134645E-A12D-4143-898F-C2D5C9DE5F4F}.Release|x64.Build.0 = Release|x64
{2134645E-A12D-4143-898F-C2D5C9DE5F4F}.Release|x86.ActiveCfg = Release|Win32
{2134645E-A12D-4143-898F-C2D5C9DE5F4F}.Release|x86.Build.0 = Release|Win32
{33B48397-2D59-4D3F-B18C-BF52CC4A3785}.Debug|x64.ActiveCfg = Debug|x64
{33B48397-2D59-4D3F-B18C-BF52CC4A3785}.Debug|x64.Build.0 = Debug|x64
{33B48397-2D59-4D3F-B18C-BF52CC4A3785}.Debug|x86.ActiveCfg = Debug|Win32
{33B48397-2D59-4D3F-B18C-BF52CC4A3785}.Debug|x86.Build.0 = Debug|Win32
{33B48397-2D59-4D3F-B18C-BF52CC4A3785}.Release|x64.ActiveCfg = Release|x64
{33B48397-2D59-4D3F-B18C-BF52CC4A3785}.Release|x64.Build.0 = Release|x64
{33B48397-2D59-4D3F-B18C-BF52CC4A3785}.Release|x86.ActiveCfg = Release|Win32
{33B48397-2D59-4D3F-B18C-BF52CC4A3785}.Release|x86.Build.0 = Release|Win32
{4A519CF2-1985-46E5-B701-A3B48E8DE940}.Debug|x64.ActiveCfg = Debug|x64
{4A519CF2-1985-46E5-B701-A3B48E8DE940}.Debug|x64.Build.0 = Debug|x64
{4A519CF2-1985-46E5-B701-A3B48E8DE940}.Debug|x86.ActiveCfg = Debug|Win32
{4A519CF2-1985-46E5-B701-A3B48E8DE940}.Debug|x86.Build.0 = Debug|Win32
{4A519CF2-1985-46E5-B701-A3B48E8DE940}.Release|x64.ActiveCfg = Release|x64
{4A519CF2-1985-46E5-B701-A3B48E8DE940}.Release|x64.Build.0 = Release|x64
{4A519CF2-1985-46E5-B701-A3B48E8DE940}.Release|x86.ActiveCfg = Release|Win32
{4A519CF2-1985-46E5-B701-A3B48E8DE940}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{33B48397-2D59-4D3F-B18C-BF52CC4A3785} = {9B6D7C1A-6E3F-4F0B-9E9C-0B5C6A8F2E77}
{4A519CF2-1985-46E5-B701-A3B48E8DE940} = {9B6D7C1A-6E3F-4F0B-9E9C-0B5C6A8F2E77}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A4049FF9-DC7D-4D1A-9567-76389B7C83BA}
EndGlobalSection
Expand Down
26 changes: 0 additions & 26 deletions C++/Forward/Forward.cpp

This file was deleted.

22 changes: 0 additions & 22 deletions C++/LambdaFunctions/ConsoleApplication1.vcxproj.filters

This file was deleted.

4 changes: 0 additions & 4 deletions C++/LambdaFunctions/ConsoleApplication1.vcxproj.user

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include <iostream>
#include <string>
#include <tuple>
#include "SortPerformance.h"
using namespace std;

class MyClass {
public:
int value; // Integer member
Expand All @@ -23,7 +25,7 @@ bool IsEven(MyClass mclass)
int main()
{

std::vector<std::pair<const std::string&,double>> clausesOrdered =
std::vector<std::pair<std::string,double>> clausesOrdered =
{
{"banana", 1},
{"apple", 4},
Expand Down Expand Up @@ -78,5 +80,8 @@ int main()
std::cout << "No object with an even value found." << std::endl;
}

std::cout << std::endl;
RunSortPerformanceExample();

return 0;
}
8 changes: 6 additions & 2 deletions C++/LambdaFunctions/LambdaFunctions.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{9eb235c6-2f83-4da8-969b-0f1e9dc735c8}</ProjectGuid>
<RootNamespace>ConsoleApplication1</RootNamespace>
<RootNamespace>LambdaFunctions</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Expand Down Expand Up @@ -140,7 +140,11 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ConsoleApplication1.cpp" />
<ClCompile Include="LambdaFunctions.cpp" />
<ClCompile Include="SortPerformance.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="SortPerformance.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
57 changes: 57 additions & 0 deletions C++/LambdaFunctions/SortPerformance.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SortPerformance.cpp : demonstrates measuring std::sort performance on random vs. already-sorted data.
//

#include "SortPerformance.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <chrono>

void generateRandomNumbers(std::vector<int>& vec, int size) {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(1, 10000);

vec.clear();
vec.reserve(size);
for (int i = 0; i < size; ++i) {
vec.push_back(dis(gen));
}
}


void measurePerformance(const std::vector<int>& vec, const std::string& description) {
auto start = std::chrono::high_resolution_clock::now();
std::vector<int> sortedVec = vec;
std::sort(sortedVec.begin(), sortedVec.end());
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> sortDuration = end - start;
std::cout << "Time taken to sort " << description << ": " << sortDuration.count() << " seconds\n";

start = std::chrono::high_resolution_clock::now();
bool isSorted = std::is_sorted(sortedVec.begin(), sortedVec.end());
end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> checkDuration = end - start;
std::cout << "Time taken to check if sorted " << description << ": " << checkDuration.count() << " seconds\n";
std::cout << "Array is sorted: " << (isSorted ? "true" : "false") << "\n";

if (description == "already sorted array") {
std::cout << "Performance improvement for checking sorted array: "
<< (sortDuration.count() / checkDuration.count()) << " times faster\n";
}
}

void RunSortPerformanceExample()
{
const int size = 10000;
std::vector<int> vec;
generateRandomNumbers(vec, size);

std::cout << "Performance with random array:\n";
measurePerformance(vec, "random array");

std::cout << "\nPerformance with already sorted array:\n";
std::sort(vec.begin(), vec.end());
measurePerformance(vec, "already sorted array");
}
4 changes: 4 additions & 0 deletions C++/LambdaFunctions/SortPerformance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once

// Demonstrates measuring std::sort performance on random vs. already-sorted data.
void RunSortPerformanceExample();
64 changes: 64 additions & 0 deletions C++/MoveSemantics/DynamicBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "DynamicBuffer.h"
#include <utility>

DynamicBuffer::DynamicBuffer(std::size_t elementCount)
: m_data(new double[elementCount]{}), m_count(elementCount)
{
}

// 1. Destructor - releases owned memory
DynamicBuffer::~DynamicBuffer()
{
delete[] m_data;
}

// 2. Copy constructor - deep copies the buffer
DynamicBuffer::DynamicBuffer(const DynamicBuffer& source)
: m_data(new double[source.m_count]), m_count(source.m_count)
{
for (std::size_t i = 0; i < m_count; ++i)
{
m_data[i] = source.m_data[i];
}
}

// 3. Copy assignment operator - deep copies, releasing old memory first
DynamicBuffer& DynamicBuffer::operator=(const DynamicBuffer& source)
{
if (this != &source)
{
double* newData = new double[source.m_count];
for (std::size_t i = 0; i < source.m_count; ++i)
{
newData[i] = source.m_data[i];
}

delete[] m_data;
m_data = newData;
m_count = source.m_count;
}
return *this;
}

// 4. Move constructor - steals the pointer, leaves source empty
DynamicBuffer::DynamicBuffer(DynamicBuffer&& source) noexcept
: m_data(source.m_data), m_count(source.m_count)
{
source.m_data = nullptr;
source.m_count = 0;
}

// 5. Move assignment operator - releases old memory, steals new pointer
DynamicBuffer& DynamicBuffer::operator=(DynamicBuffer&& source) noexcept
{
if (this != &source)
{
delete[] m_data;
m_data = source.m_data;
m_count = source.m_count;

source.m_data = nullptr;
source.m_count = 0;
}
return *this;
}
34 changes: 34 additions & 0 deletions C++/MoveSemantics/DynamicBuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once
#include <cstddef>

// Demonstrates the Rule of Five: a resource-owning class must define
// (or explicitly default) all five special member functions if it
// manages a raw resource such as heap memory.
class DynamicBuffer
{
public:
explicit DynamicBuffer(std::size_t elementCount = 10);

// 1. Destructor - releases owned memory
~DynamicBuffer();

// 2. Copy constructor - deep copies the buffer
DynamicBuffer(const DynamicBuffer& source);

// 3. Copy assignment operator - deep copies, releasing old memory first
DynamicBuffer& operator=(const DynamicBuffer& source);

// 4. Move constructor - steals the pointer, leaves source empty
DynamicBuffer(DynamicBuffer&& source) noexcept;

// 5. Move assignment operator - releases old memory, steals new pointer
DynamicBuffer& operator=(DynamicBuffer&& source) noexcept;

std::size_t count() const noexcept { return m_count; }
double& at(std::size_t index) { return m_data[index]; }
double at(std::size_t index) const { return m_data[index]; }

private:
double* m_data;
std::size_t m_count;
};
Loading
Loading