Skip to content

Commit 2de850a

Browse files
committed
Initial commit
0 parents  commit 2de850a

15 files changed

+540159
-0
lines changed

.editorconfig

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
# .NET coding convention settings for EditorConfig
3+
# https://learn.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference
4+
#
5+
# This file comes from dotnet repositories:
6+
# https://github.com/dotnet/runtime/blob/master/.editorconfig
7+
# https://github.com/dotnet/roslyn/blob/master/.editorconfig
8+
9+
# Top-most EditorConfig file
10+
root = true
11+
12+
[*]
13+
charset = utf-8
14+
# indent_size intentionally not specified in this section
15+
indent_style = space
16+
insert_final_newline = true
17+
18+
# Source code
19+
[*.{cs,ps1,psd1,psm1}]
20+
indent_size = 4
21+
22+
# Shell scripts
23+
[*.sh]
24+
end_of_line = lf
25+
indent_size = 4
26+
27+
# Xml project files
28+
[*.{csproj,resx,ps1xml}]
29+
indent_size = 2
30+
31+
# Data serialization
32+
[*.{json,yaml,yml}]
33+
indent_size = 2
34+
35+
# Markdown
36+
[*.md]
37+
indent_size = 2
38+
39+
# Xml files
40+
[*.{resx,ruleset,stylecop,xml,xsd,xsl}]
41+
indent_size = 2
42+
43+
# Xml config files
44+
[*.{props,targets,config,nuspec}]
45+
indent_size = 2
46+
47+
[*.tsv]
48+
indent_style = tab
49+
50+
# Dotnet code style settings:
51+
[*.cs]
52+
# Sort using and Import directives with System.* appearing first
53+
dotnet_sort_system_directives_first = true
54+
55+
file_header_template = Licensed under the MIT License.
56+
57+
# Modifier preferences
58+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
59+
60+
# Avoid "this." and "Me." if not necessary
61+
dotnet_style_qualification_for_field = false:suggestion
62+
dotnet_style_qualification_for_property = false:suggestion
63+
dotnet_style_qualification_for_method = false:suggestion
64+
dotnet_style_qualification_for_event = false:suggestion
65+
66+
# Use language keywords instead of framework type names for type references
67+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
68+
dotnet_style_predefined_type_for_member_access = true:suggestion
69+
70+
# Name all constant fields using PascalCase
71+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
72+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
73+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
74+
75+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
76+
dotnet_naming_symbols.constant_fields.required_modifiers = const
77+
78+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
79+
80+
# Static fields should have s_ prefix
81+
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
82+
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
83+
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
84+
85+
dotnet_naming_symbols.static_fields.applicable_kinds = field
86+
dotnet_naming_symbols.static_fields.required_modifiers = static
87+
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
88+
89+
dotnet_naming_style.static_prefix_style.required_prefix = s_
90+
dotnet_naming_style.static_prefix_style.capitalization = camel_case
91+
92+
# Internal and private fields should be _camelCase
93+
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
94+
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
95+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
96+
97+
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
98+
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
99+
100+
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
101+
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
102+
103+
# Suggest more modern language features when available
104+
dotnet_style_object_initializer = true:suggestion
105+
dotnet_style_collection_initializer = true:suggestion
106+
dotnet_style_coalesce_expression = true:suggestion
107+
dotnet_style_null_propagation = true:suggestion
108+
dotnet_style_explicit_tuple_names = true:suggestion
109+
dotnet_style_readonly_field = true:suggestion
110+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
111+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
112+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
113+
dotnet_style_prefer_conditional_expression_over_return = true:silent
114+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
115+
dotnet_style_prefer_auto_properties = true:suggestion
116+
csharp_prefer_simple_default_expression = true:suggestion
117+
118+
dotnet_code_quality_unused_parameters = non_public:suggestion
119+
120+
# CSharp code style settings:
121+
[*.cs]
122+
123+
csharp_preserve_single_line_blocks = true
124+
csharp_preserve_single_line_statements = false
125+
csharp_prefer_braces = true:warning
126+
127+
csharp_prefer_static_local_function = true:suggestion
128+
csharp_prefer_simple_using_statement = false:none
129+
csharp_style_prefer_switch_expression = true:suggestion
130+
csharp_style_prefer_range_operator = false:none
131+
csharp_style_prefer_index_operator = false:none
132+
csharp_style_pattern_local_over_anonymous_function = false:none
133+
134+
csharp_using_directive_placement = outside_namespace:suggestion
135+
136+
# Indentation preferences
137+
csharp_indent_block_contents = true
138+
csharp_indent_braces = false
139+
csharp_indent_case_contents = true
140+
csharp_indent_case_contents_when_block = true
141+
csharp_indent_switch_labels = true
142+
csharp_indent_labels = one_less_than_current
143+
144+
# Only use var when it's obvious what the variable type is
145+
csharp_style_var_for_built_in_types = false:none
146+
csharp_style_var_when_type_is_apparent = false:none
147+
csharp_style_var_elsewhere = false:suggestion
148+
149+
# Expression-bodied members
150+
csharp_style_expression_bodied_local_functions = true:silent
151+
152+
# Prefer method-like constructs to have a block body
153+
csharp_style_expression_bodied_methods = false:none
154+
csharp_style_expression_bodied_constructors = false:none
155+
csharp_style_expression_bodied_operators = false:none
156+
157+
# Prefer property-like constructs to have an expression-body
158+
csharp_style_expression_bodied_properties = true:none
159+
csharp_style_expression_bodied_indexers = true:none
160+
csharp_style_expression_bodied_accessors = true:none
161+
162+
# Suggest more modern language features when available
163+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
164+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
165+
csharp_style_inlined_variable_declaration = true:suggestion
166+
csharp_style_throw_expression = true:suggestion
167+
csharp_style_conditional_delegate_call = true:suggestion
168+
169+
# Space preferences
170+
csharp_space_after_cast = false
171+
csharp_space_after_colon_in_inheritance_clause = true
172+
csharp_space_after_comma = true
173+
csharp_space_after_dot = false
174+
csharp_space_after_keywords_in_control_flow_statements = true
175+
csharp_space_after_semicolon_in_for_statement = true
176+
csharp_space_around_binary_operators = before_and_after
177+
csharp_space_around_declaration_statements = do_not_ignore
178+
csharp_space_before_colon_in_inheritance_clause = true
179+
csharp_space_before_comma = false
180+
csharp_space_before_dot = false
181+
csharp_space_before_open_square_brackets = false
182+
csharp_space_before_semicolon_in_for_statement = false
183+
csharp_space_between_empty_square_brackets = false
184+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
185+
csharp_space_between_method_call_name_and_opening_parenthesis = false
186+
csharp_space_between_method_call_parameter_list_parentheses = false
187+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
188+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
189+
csharp_space_between_method_declaration_parameter_list_parentheses = false
190+
csharp_space_between_parentheses = false
191+
csharp_space_between_square_brackets = false
192+
193+
# Newline settings
194+
csharp_new_line_before_open_brace = all
195+
csharp_new_line_before_else = true
196+
csharp_new_line_before_catch = true
197+
csharp_new_line_before_finally = true
198+
csharp_new_line_before_members_in_object_initializers = true
199+
csharp_new_line_before_members_in_anonymous_types = true
200+
csharp_new_line_between_query_expression_clauses = true
201+
202+
# IDE0090: Use 'new(...)'
203+
csharp_style_implicit_object_creation_when_type_is_apparent = false
204+
205+
# IDE0160: Convert to block scoped namespace
206+
dotnet_diagnostic.IDE0160.severity = none
207+
208+
# IDE0130: Namespace does not match folder structure
209+
dotnet_diagnostic.IDE0130.severity = none

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CHANGELOG.md merge=union
2+
* text=auto
3+
*.png binary
4+
*.rtf binary
5+
*.sh text eol=lf

.gitignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
bin/
2+
obj/
3+
BenchmarkDotNet.Artifacts/
4+
project.lock.json
5+
/perf
6+
/debug/
7+
/staging/
8+
/Packages/
9+
*.nuget.props
10+
11+
# VS auto-generated files for csproj files
12+
*.csproj.user
13+
14+
# Visual Studio IDE directory
15+
.vs/
16+
17+
# VSCode directories that are not at the repository root
18+
/**/.vscode/
19+
20+
# Ignore executables
21+
*.exe
22+
*.msi
23+
*.appx
24+
*.msix
25+
26+
# Ignore binaries and symbols
27+
*.pdb
28+
*.dll
29+
*.wixpdb
30+
31+
# Ignore packages
32+
*.deb
33+
*.tar.gz
34+
*.zip
35+
*.rpm
36+
*.pkg
37+
*.nupkg
38+
*.AppImage
39+
40+
# default location for produced nuget packages
41+
/nuget-artifacts
42+
43+
# resgen output
44+
gen
45+
46+
# TestsResults
47+
TestsResults*.xml
48+
ParallelXUnitResults.xml
49+
xUnitResults.xml
50+
51+
# BenchmarkDotNet artifacts
52+
perf/BenchmarkDotNet.Artifacts/
53+
54+
# Ignore logfiles
55+
logfile/*

BinaryTrie.sln

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinaryTrie.Tests", "tests\BinaryTrieTests.csproj", "{AC41494E-48D6-4C36-855F-8F637EB95F24}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinaryTrie", "src\BinaryTrie.csproj", "{AF74320D-5975-4AE6-8C1D-049F67312F8D}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinaryTrie.Perf", "perf\BinaryTrie.Perf.csproj", "{7E2DCBC2-9DCC-4594-A9E5-415D67F2F9CC}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinaryTrieStats", "stats\BinaryTrieStats.csproj", "{60DC5706-61FA-4BCC-AE07-FFDA7F68DE09}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Release|Any CPU = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23+
{AC41494E-48D6-4C36-855F-8F637EB95F24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{AC41494E-48D6-4C36-855F-8F637EB95F24}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{AC41494E-48D6-4C36-855F-8F637EB95F24}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{AC41494E-48D6-4C36-855F-8F637EB95F24}.Release|Any CPU.Build.0 = Release|Any CPU
27+
{AF74320D-5975-4AE6-8C1D-049F67312F8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{AF74320D-5975-4AE6-8C1D-049F67312F8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{AF74320D-5975-4AE6-8C1D-049F67312F8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{AF74320D-5975-4AE6-8C1D-049F67312F8D}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{7E2DCBC2-9DCC-4594-A9E5-415D67F2F9CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{7E2DCBC2-9DCC-4594-A9E5-415D67F2F9CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{7E2DCBC2-9DCC-4594-A9E5-415D67F2F9CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{7E2DCBC2-9DCC-4594-A9E5-415D67F2F9CC}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{C1C98AD5-5A17-45AD-A450-D405EFEC6016}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{C1C98AD5-5A17-45AD-A450-D405EFEC6016}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{C1C98AD5-5A17-45AD-A450-D405EFEC6016}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{C1C98AD5-5A17-45AD-A450-D405EFEC6016}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{60DC5706-61FA-4BCC-AE07-FFDA7F68DE09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{60DC5706-61FA-4BCC-AE07-FFDA7F68DE09}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{60DC5706-61FA-4BCC-AE07-FFDA7F68DE09}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{60DC5706-61FA-4BCC-AE07-FFDA7F68DE09}.Release|Any CPU.Build.0 = Release|Any CPU
43+
EndGlobalSection
44+
EndGlobal

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) I.E.Sazonov.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# BinaryTrie IP Lookup (multi-thread)
2+
3+
C# binary trie implementation is designed to search for an information (`TLeaf`) associated with IP network. Notice, it is not for routing but for applications, with balanced lookup/add/remove operations performance in mind. The implementation is thread-safe, `Lookup()` is lock-free (many threads can look up concurrently), `AddOrUpdate()` and `Remove()` use a lock (only one thread can modify the `IPBinaryTrie<TLeaf>` in the same time).
4+
5+
## Usage
6+
7+
See sources in `tests` folder.
8+
9+
## Build
10+
11+
```cmd
12+
cd .\src
13+
dotnet build
14+
```
15+
16+
## Build package
17+
18+
```cmd
19+
cd .\src
20+
dotnet pack
21+
```
22+
23+
## Run xUnit tests
24+
25+
```cmd
26+
cd .\tests
27+
dotnet test
28+
```
29+
30+
## Run performance tests
31+
32+
```cmd
33+
cd .\perf
34+
dotnet run -c Release -f net8.0 -- -r net8.0 net9.0 --iterationCount 32 -f *
35+
```
36+
37+
## Run statistics
38+
39+
```cmd
40+
cd .\stats
41+
dotnet run
42+
```

0 commit comments

Comments
 (0)