Skip to content

Commit

Permalink
Merge pull request #95 from AzuxirenLeadGuy/master
Browse files Browse the repository at this point in the history
Added B-Tree Data Structure
  • Loading branch information
ZacharyPatten authored Jan 7, 2022
2 parents 0afeb23 + f816d5e commit c85e741
Show file tree
Hide file tree
Showing 9 changed files with 1,007 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/Continuous Integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ jobs:
with:
dotnet-version: 6.0.x
- name: dotnet build
run: dotnet build --configuration 'Release'
run: dotnet build --configuration Release /nowarn:cs1030
- name: dotnet test
run: dotnet test --configuration 'Release'
run: dotnet test --configuration Release /nowarn:cs1030
2 changes: 1 addition & 1 deletion .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
dotnet-version: 6.0.x
- name: dotnet test
run: dotnet test --collect:"XPlat Code Coverage"
run: dotnet test --collect:"XPlat Code Coverage" /nowarn:cs1030
- name: find coverage.cobertura.xml path
run: find . -print | grep -i 'coverage.cobertura.xml' > COVERAGEPATH.txt
- name: move coverage.cobertura.xml file
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Towel Deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
with:
dotnet-version: 6.0.x
- name: dotnet pack
run: dotnet pack Sources/Towel/Towel.csproj --configuration Release /p:Version=${{ github.event.release.tag_name }} /p:PackageReleaseNotes="See https://github.com/ZacharyPatten/Towel/releases/tag/${{ github.event.release.tag_name }}"
run: dotnet pack Sources/Towel/Towel.csproj --configuration Release /p:Version=${{ github.event.release.tag_name }} /p:PackageReleaseNotes="See https://github.com/ZacharyPatten/Towel/releases/tag/${{ github.event.release.tag_name }}" /nowarn:cs1030
- name: archive nuget
uses: actions/upload-artifact@v1
with:
Expand Down
94 changes: 47 additions & 47 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,51 @@
"**/bin": true,
"**/obj": true
},
"csharp.semanticHighlighting.enabled": true,

// color/theme settings
"workbench.colorTheme": "Default Dark+",
"editor.semanticTokenColorCustomizations":
{
"[Default Dark+]":
{
"enabled": true,
"rules":
{
"class": "#4EC9B0",
"comment": "#57A64A",
"controlKeyword": "#569CD6",
"delegate": "#BD63C5",
"enum": "#FF7F27",
"enumMember": "#ffffff",
"event": "#ffffff",
"excludedCode": "#9B9B9B",
"extensionMethod": "#CB859B",
"field": "#ffffff",
"interface": "#B8D7A3",
"keyword": "#569CD6",
"label": "#ffffff",
"local": "#ffffff",
"method": "#BD6380",
"namespace": "#ffffff",
"number": "#B8D7A3",
"operator": "#ffffff",
"operatorOverloaded": "#ffffff",
"parameter": "#ffffff",
"plainKeyword": "#569CD6",
"preprocessorKeyword": "#9B9B9B",
"preprocessorText": "#ffffff",
"property": "#ffffff",
"punctuation": "#ffffff",
"string": "#D69D85",
"stringVerbatim": "#D69D85",
"struct": "#FFFF80",
"typeParameter": "#808000",
"variable": "#ffffff",
"xmlDocCommentComment": "#56a64a7c",
"xmlDocCommentText": "#9B9B9B",
"xmlDocCommentAttributeName": "#9B9B9B"
}
}
}
"csharp.semanticHighlighting.enabled": true
//// theme settings
//"workbench.colorTheme": "Default Dark+",
//"editor.semanticTokenColorCustomizations":
//{
// "[Default Dark+]":
// {
// "enabled": true,
// "rules":
// {
// "class": "#4EC9B0",
// "comment": "#57A64A",
// "controlKeyword": "#569CD6",
// "delegate": "#BD63C5",
// "enum": "#FF7F27",
// "enumMember": "#ffffff",
// "event": "#ffffff",
// "excludedCode": "#9B9B9B",
// "extensionMethod": "#CB859B",
// "field": "#ffffff",
// "interface": "#B8D7A3",
// "keyword": "#569CD6",
// "label": "#ffffff",
// "local": "#ffffff",
// "method": "#BD6380",
// "namespace": "#ffffff",
// "number": "#B8D7A3",
// "operator": "#ffffff",
// "operatorOverloaded": "#ffffff",
// "parameter": "#ffffff",
// "plainKeyword": "#569CD6",
// "preprocessorKeyword": "#9B9B9B",
// "preprocessorText": "#ffffff",
// "property": "#ffffff",
// "punctuation": "#ffffff",
// "string": "#D69D85",
// "stringVerbatim": "#D69D85",
// "struct": "#FFFF80",
// "typeParameter": "#808000",
// "variable": "#ffffff",
// "xmlDocCommentComment": "#56a64a7c",
// "xmlDocCommentText": "#9B9B9B",
// "xmlDocCommentAttributeName": "#9B9B9B"
// }
// }
//}
}
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,66 @@
>
> <details>
> <summary>
> :page_facing_up: B-Tree <sub>[Expand]</sub>
> </summary>
> <p>
>
> > ```cs
> > // a B-tree is a self-balancing tree data structure that maintains
> > // sorted data and allows searches, sequential access, insertions,
> > // and deletions in logarithmic time. The B-tree generalizes the
> > // binary search tree, allowing for nodes with more than two children.
> >
> > // There are two ways to Add and Remove elements in a B-Tree
> > // 1) Pre-emptive: Search the tree from top to bottom (for place to add/
> > // node to delete) and perform fixing of the B-Tree (Splitting
> > // or Merging) in a single pass
> > // 2) Non Pre-emptive: Add/Remove the required node and go up the tree to
> > // fix the tree as needed
> > //
> > // Pre-emptive methods are optimal, especially if the Maximum Degree of
> > // a node is set to an even number. This implementation of B-Tree
> > // uses Pre-emptive modes of Add/Removal methods and therefore the
> > // value of Maximum Degree is mandated to be even
> >
> > // This implementation is taken from Thomas H. Cormen's book "Introduction
> > // to Algorithms, 3rd edition", Chapter 18: B-Trees
> >
> > BTree<int> tree = new BTree<int>(4);
> >
> > tree.Add(20);
> > tree.Add(10);
> > tree.Add(30);
> > tree.Add(50);
> > tree.Add(40);
> > tree.Add(5);
> > tree.Add(15);
> > //
> > // [20]
> > // / \
> > // / \
> > // [5, 10, 15] [30, 40, 50]
> > //
> > // All elements added in the BTree, where each node can have a maximum
> > // of 4 children (and therefore, a maximum of 3 elements)
> >
> > bool r1 = tree.TryRemove(50).Success; // r1 = true
> > bool r2 = tree.TryRemove(50).Success; // r2 = false, 50 is no longer in the tree
> >
> > //
> > // [20]
> > // / \
> > // / \
> > // [5, 10, 15] [30, 40]
> >
> > int[] array = tree.ToArray(); // array = [5, 10, 15, 20, 30, 40]
> > ```
> >
> </p>
> </details>
>
> <details>
> <summary>
> :page_facing_up: Tree <sub>[Expand]</sub>
> </summary>
> <p>
Expand Down
Loading

0 comments on commit c85e741

Please sign in to comment.