diff --git a/DataStructure/.vscode/launch.json b/DataStructure/.vscode/launch.json new file mode 100644 index 0000000..839fd02 --- /dev/null +++ b/DataStructure/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // IntelliSense를 사용하여 가능한 특성에 대해 알아보세요. + // 기존 특성에 대한 설명을 보려면 가리킵니다. + // 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요. + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/treeStructure/bin/Debug/net7.0/treeStructure.dll", + "args": [], + "cwd": "${workspaceFolder}/treeStructure", + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/DataStructure/.vscode/tasks.json b/DataStructure/.vscode/tasks.json new file mode 100644 index 0000000..47df765 --- /dev/null +++ b/DataStructure/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/treeStructure/treeStructure.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/treeStructure/treeStructure.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/treeStructure/treeStructure.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/DataStructure/dataStructure.sln b/DataStructure/dataStructure.sln new file mode 100644 index 0000000..af04c68 --- /dev/null +++ b/DataStructure/dataStructure.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "hashTableStructure", "hashTableStructure\hashTableStructure.csproj", "{BCDB71EB-A69C-4A7E-922D-B4B0A2EA381B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "treeStructure", "treeStructure\treeStructure.csproj", "{C5273712-749A-4975-A15D-943673D43F57}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "graphStructure", "graphStructure\graphStructure.csproj", "{DE34364A-4934-4ACE-9BF0-742FCA7B2B2B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "heapStructure", "heapStructure\heapStructure.csproj", "{45886642-579F-4EB2-8314-E41558743140}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BCDB71EB-A69C-4A7E-922D-B4B0A2EA381B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BCDB71EB-A69C-4A7E-922D-B4B0A2EA381B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BCDB71EB-A69C-4A7E-922D-B4B0A2EA381B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BCDB71EB-A69C-4A7E-922D-B4B0A2EA381B}.Release|Any CPU.Build.0 = Release|Any CPU + {C5273712-749A-4975-A15D-943673D43F57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5273712-749A-4975-A15D-943673D43F57}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5273712-749A-4975-A15D-943673D43F57}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5273712-749A-4975-A15D-943673D43F57}.Release|Any CPU.Build.0 = Release|Any CPU + {DE34364A-4934-4ACE-9BF0-742FCA7B2B2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE34364A-4934-4ACE-9BF0-742FCA7B2B2B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE34364A-4934-4ACE-9BF0-742FCA7B2B2B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE34364A-4934-4ACE-9BF0-742FCA7B2B2B}.Release|Any CPU.Build.0 = Release|Any CPU + {45886642-579F-4EB2-8314-E41558743140}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45886642-579F-4EB2-8314-E41558743140}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45886642-579F-4EB2-8314-E41558743140}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45886642-579F-4EB2-8314-E41558743140}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/DataStructure/graphStructure/Program.cs b/DataStructure/graphStructure/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/DataStructure/graphStructure/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/DataStructure/graphStructure/graphStructure.csproj b/DataStructure/graphStructure/graphStructure.csproj new file mode 100644 index 0000000..f02677b --- /dev/null +++ b/DataStructure/graphStructure/graphStructure.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/DataStructure/hashTableStructure/Program.cs b/DataStructure/hashTableStructure/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/DataStructure/hashTableStructure/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/DataStructure/hashTableStructure/hashTableStructure.csproj b/DataStructure/hashTableStructure/hashTableStructure.csproj new file mode 100644 index 0000000..f02677b --- /dev/null +++ b/DataStructure/hashTableStructure/hashTableStructure.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/DataStructure/heapStructure/Program.cs b/DataStructure/heapStructure/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/DataStructure/heapStructure/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/DataStructure/heapStructure/heapStructure.csproj b/DataStructure/heapStructure/heapStructure.csproj new file mode 100644 index 0000000..f02677b --- /dev/null +++ b/DataStructure/heapStructure/heapStructure.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/DataStructure/treeStructure/Program.cs b/DataStructure/treeStructure/Program.cs new file mode 100644 index 0000000..b161f95 --- /dev/null +++ b/DataStructure/treeStructure/Program.cs @@ -0,0 +1,16 @@ +using treeStructure.Structure; + +namespace treeStructure +{ + static class Program + { + static void Main(string[] args) + { + //UseHashTable.DoWork(); + + // UseDictionary.DoWork(); + + UseConcurrentDictionary.DoWork(); + } + } +} \ No newline at end of file diff --git a/DataStructure/treeStructure/Structure/UseConcurrentDictionary.cs b/DataStructure/treeStructure/Structure/UseConcurrentDictionary.cs new file mode 100644 index 0000000..aa4b391 --- /dev/null +++ b/DataStructure/treeStructure/Structure/UseConcurrentDictionary.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections; +using System.Collections.Concurrent; +using System.Threading; +using System.Threading.Tasks; + +namespace treeStructure.Structure +{ + public class UseConcurrentDictionary + { + public static void DoWork() + { + ConcurrentDictionary dict = new ConcurrentDictionary(); + + Task t1 = Task.Factory.StartNew(() => + { + int key = 1; + while (key <= 100) + { + if (dict.TryAdd(key, $"D{key}")) + key++; + + Thread.Sleep(100); + } + }); + + Task t2 = Task.Factory.StartNew(() => + { + int key = 1; + string val; + while (key <= 100) + { + if (dict.TryGetValue(key, out val)) + { + Console.WriteLine($"[{key}] {val}"); + key++; + } + + Thread.Sleep(100); + } + }); + + Task.WaitAll(t1, t2); + } + } +} \ No newline at end of file diff --git a/DataStructure/treeStructure/Structure/UseDictionary.cs b/DataStructure/treeStructure/Structure/UseDictionary.cs new file mode 100644 index 0000000..542dc14 --- /dev/null +++ b/DataStructure/treeStructure/Structure/UseDictionary.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections; + +namespace treeStructure.Structure +{ + public class UseDictionary + { + public static void DoWork() + { + Dictionary emp = new Dictionary(); + emp.Add(1001, "Jane"); + emp.Add(1002, "Tom"); + emp.Add(1003, "Cindy"); + + string name = emp[1002]; + Console.WriteLine(name); + } + } +} \ No newline at end of file diff --git a/DataStructure/treeStructure/Structure/UseHashTable.cs b/DataStructure/treeStructure/Structure/UseHashTable.cs new file mode 100644 index 0000000..4b2d72a --- /dev/null +++ b/DataStructure/treeStructure/Structure/UseHashTable.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections; + +namespace treeStructure.Structure +{ + public class UseHashTable + { + public static void DoWork() + { + Hashtable ht = new Hashtable(); + ht.Add("irina", "Irina SP"); + ht.Add("tom", "Tom cr"); + + if (ht.Contains("tom")) + Console.WriteLine(ht["tom"]); + } + } +} \ No newline at end of file diff --git a/DataStructure/treeStructure/treeStructure.csproj b/DataStructure/treeStructure/treeStructure.csproj new file mode 100644 index 0000000..f02677b --- /dev/null +++ b/DataStructure/treeStructure/treeStructure.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + +