Skip to content

Commit

Permalink
Merge branch 'feature/Deque' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ByronMayne committed Oct 22, 2023
2 parents a151ef7 + 6057902 commit afef666
Show file tree
Hide file tree
Showing 12 changed files with 1,116 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
"commands": [
"dotnet-gitversion"
]
},
"coverlet.console": {
"version": "6.0.0",
"commands": [
"coverlet"
]
}
}
}
8 changes: 6 additions & 2 deletions .github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ jobs:
env:
SourceDir: ./src/
Configuration: Release
Framework: netstandard2.0
Solution_Path: ./src/Extended.Collections.sln
Library_Dir: ./src/Extended.Collections/
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -29,8 +31,10 @@ jobs:
- name: Build
run: dotnet build ${Solution_Path} -p:Version=${{env.GitVersion_AssemblySemVer}}
- name: Execute unit tests
run: dotnet test ${Solution_Path} --no-build
run: dotnet test ${Solution_Path} --no-build -p:CollectCoverage=true --collect:"XPlat Code Coverage"
# - name: Generate Code Coverage
# run: dotnet coverlet ${Library_Dir}bin/${Configuration}/${Framework}/Extended.Collections.dll
- name: Pack
run: dotnet msbuild -t:pack ${Solution_Path} -p:PackageVersion=${{env.GitVersion_NuGetVersion}} -p:NoBuild=true
- name: Push
run: dotnet nuget push ./src/Extended.Collections/bin/${Configuration}/*.nupkg --skip-duplicate --api-key ${{secrets.NuGet_Api_Key}} --source ${{vars.Nuget_Source_Url}}
run: dotnet nuget push ${Library_Dir}bin/${Configuration}/*.nupkg --skip-duplicate --api-key ${{secrets.NuGet_Api_Key}} --source ${{vars.Nuget_Source_Url}}
25 changes: 25 additions & 0 deletions documentation/generic/deque.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Deque

A double-ended queue, often abbreviated as "deque" (pronounced as "deck"), is a linear data structure that allows elements to be added or removed from both ends efficiently. It is an extension of a queue and a stack, providing operations for adding and removing elements from the front and back. Deques can be implemented using arrays or linked lists, and they are useful in scenarios where you need to perform insertions and deletions at both ends of the data structure.

## Advantages
* Efficient Operations: Deques allow constant-time (O(1)) insertion and removal of elements at both ends, making them suitable for various algorithms and data manipulation tasks.
* Versatility: Deques can serve as both a queue and a stack, providing flexibility in implementing various data structures and algorithms.
* Fast Access: Deques provide fast access to both the front and rear elements, enabling efficient traversal and search operations.

## Disadvantages
* Memory Overhead: Depending on the implementation, deques may require additional memory compared to simpler data structures like arrays or linked lists.
* Complexity: Implementing and maintaining a deque can be more complex than using a simple stack or queue, especially when dealing with dynamic resizing.

# Code
```csharp file=../../src/Extended.Collections.Playground/Generic/DequeSandbox.cs#L2-
// Imported
```

```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
12 changes: 12 additions & 0 deletions documentation/generic/ring_buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
A ring buffer is a data structure that efficiently manages a fixed-size, cyclically-referenced buffer, allowing for constant-time insertions and removals while overwriting the oldest data when full.


## Advantages
* **Constant Time Complexity for Insertions and Deletions**: Ring buffers offer O(1) time complexity for both inserting elements (enqueue) and removing elements (dequeue) as long as the buffer is not full or empty. This makes them highly efficient for real-time applications where performance matters.
* **Fixed and Predictable Memory Usage**: Ring buffers have a fixed capacity, which means that memory usage is predictable and doesn't grow beyond the specified limit. This characteristic is crucial in embedded systems and other resource-constrained environments.
* **Efficient for Streaming and Circular Data**: Ring buffers are ideal for managing streaming data, such as audio, video, or sensor data, as they provide a continuous loop for storing and processing the most recent data points.
* **No Need for Dynamic Memory Allocation**: Unlike dynamic data structures like linked lists or arrays with variable sizes, ring buffers do not require dynamic memory allocation or deallocation. This eliminates potential memory fragmentation issues and improves memory management efficiency.

## Disadvantages
* **Fixed Capacity Limitation**: The fixed size of a ring buffer can be a disadvantage if the number of elements you need to store exceeds the buffer's capacity. In such cases, you would need to implement additional logic for handling overflow conditions.
* **Inefficient for Non-Circular Data**: Ring buffers are designed for circular data usage, so they are not suitable for scenarios where you need to retain all historical data without overwriting any of it.
* **Insertions May Overwrite Data**: When the buffer is full and new elements are inserted, they overwrite the oldest elements. This behavior may not be suitable for all applications, especially if you need to preserve a complete history of data.

# Code
```csharp file=../../src/Extended.Collections.Playground/Generic/RingBufferSandbox.cs#L2-
// Imported
```
3 changes: 3 additions & 0 deletions docusaurus/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ const config = {
additionalLanguages: [ 'csharp' ]
},
},
themes: [
'@docusaurus/theme-mermaid'
],
plugins: [
['@docusaurus/plugin-debug', {}],
['@docusaurus/theme-classic', {}],
Expand Down
1 change: 1 addition & 0 deletions docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@docusaurus/plugin-sitemap": "^2.4.1",
"@docusaurus/preset-classic": "2.4.1",
"@docusaurus/theme-classic": "^2.4.1",
"@docusaurus/theme-mermaid": "^2.4.1",
"@mdx-js/react": "^1.6.22",
"clsx": "^1.2.1",
"prism-react-renderer": "^1.3.5",
Expand Down
Loading

0 comments on commit afef666

Please sign in to comment.