{"id":5955,"date":"2019-01-17T00:18:18","date_gmt":"2019-01-16T15:18:18","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=5955"},"modified":"2020-05-28T13:06:46","modified_gmt":"2020-05-28T04:06:46","slug":"c-%ec%a4%91%eb%b3%b5%eb%90%9c-key%eb%a5%bc-%ed%97%88%ec%9a%a9%ed%95%98%eb%a9%b0-key%eb%a1%9c-%ec%a0%95%eb%a0%ac%eb%90%9c-%ed%95%b4%ec%89%ac%eb%a7%b5dictionary","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=5955","title":{"rendered":"[C#] \uc911\ubcf5\ub41c Key\ub97c \ud5c8\uc6a9\ud558\uba70, Key\ub85c \uc815\ub82c \ub41c \ud574\uc26c\ub9f5(Dictionary)"},"content":{"rendered":"<p>C#\uc758 \uc790\ub8cc\uad6c\uc870 \uc911 Key-Value \ucee8\ud14c\uc774\ub108\ub294 Dictionary\uc785\ub2c8\ub2e4. \uacbd\uc6b0\uc5d0 \ub530\ub77c Key\ub85c \uc815\ub82c\ub41c Dictionary\ub294 SortedDictionary \ud074\ub798\uc2a4\ub85c\uc368 C#\uc5d0\uc11c \uae30\ubcf8\uc801\uc73c\ub85c \uc81c\uacf5\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub7f0\ub370, Dictionary\uc774\ubbc0\ub85c Key\uac00 \uc911\ubcf5\ub420 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. \uc911\ubcf5\ub41c \uac12\uc744 \uc815\ub82c\ud574\uc11c \uc800\uc7a5\ud558\uae30 \uc704\ud574\uc11c\ub294 Set \uc790\ub8cc \uad6c\uc870\ub97c \uc774\uc6a9\ud574\uc57c \ud569\ub2c8\ub2e4. \uadf8\ub7f0\ub370, Set\ub294 Key\ub9cc\uc744 \uc800\uc7a5\ud560 \uc218 \uc788\uace0 Value\ub294 \uc800\uc7a5\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. \uc911\ubcf5\ub41c Key\ub97c \ud5c8\uc6a9\ud558\uba74\uc11c, Key\ub85c \uc815\ub82c\ub41c \ucee8\ud14c\uc774\ub108\ub294 \uae30\ubcf8\uc801\uc73c\ub85c C#\uc5d0\uc11c \uc81c\uacf5\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \ud558\uc9c0\ub9cc \ub450\uac1c\uc758 \ud074\ub798\uc2a4\ub97c \uc870\ud569\ud558\uba74 \uac00\ub2a5\ud55c\ub370, SortedSet\uacfc Tuple\uc785\ub2c8\ub2e4. \uc774 \ub450\uac1c\uc758 \ud074\ub798\uc2a4\ub97c \ud1b5\ud574 \uc911\ubcf5\ub41c Key\ub97c \ud5c8\uc6a9\ud558\uba74\uc11c, Key\ub85c \uc815\ub82c\ub41c \ucee8\ud14c\uc774\ub108\uc5d0 \ub300\ud55c \ud074\ub798\uc2a4\ub294 \uc544\ub798\uc640 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\npublic class SortedTupleBag&lt;TKey, TValue> : SortedSet&lt;Tuple&lt;TKey, TValue>>\r\nwhere TKey : IComparable\r\n{\r\n    private class TupleComparer : Comparer&lt;Tuple&lt;TKey, TValue>>\r\n    {\r\n        public override int Compare(Tuple&lt;TKey, TValue> x, Tuple&lt;TKey, TValue> y)\r\n        {\r\n            if (x == null || y == null) return 0;\r\n\r\n            return x.Item1.Equals(y.Item1) ? 1 : Comparer&lt;TKey>.Default.Compare(x.Item1, y.Item1);\r\n        }\r\n    }\r\n\r\n    public SortedTupleBag() : base(new TupleComparer()) { }\r\n\r\n    public void Add(TKey key, TValue value)\r\n    {\r\n        Add(new Tuple&lt;TKey, TValue>(key, value));\r\n    }\r\n}\r\n<\/pre>\n<p>\uc774 \ud074\ub798\uc2a4\uc758 \ud65c\uc6a9 \uc608\ub294 \uc544\ub798\uc758 \ucf54\ub4dc\uc640 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\nvar tuples = new SortedTupleBag&lt;double, double>();\r\n\r\ntuples.Add(10.0, 100.1);\r\ntuples.Add(40.0, 100.4);\r\ntuples.Add(10.0, 1000.1);\r\ntuples.Add(80.0, 20.8);\r\ntuples.Add(70.0, 2100.7);\r\ntuples.Add(50.0, 200.5);\r\n<\/pre>\n<p>Add \ud568\uc218\uc758 \uccab\ubc88\uc9f8\ub294 Key\uc774\uace0 \ub450\ubc88\uc9f8\ub294 Value\uc785\ub2c8\ub2e4. Key\uc758 \uc21c\uc11c\ub300\ub85c \uc815\ub82c\ub418\uc5b4 \uc788\ub294\uc9c0 \ud655\uc778\ud558\uae30 \uc704\ud574 \uc544\ub798\uc758 \ucf54\ub4dc\ub97c \ud1b5\ud574 \uc0b4\ud3b4\ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">\r\nConsole.WriteLine(\"Sorted List\");\r\nforeach (var tuple in tuples)\r\n{\r\n    Console.WriteLine(\"{0} {1}\", tuple.Item1, tuple.Item2);\r\n}\r\n\r\nConsole.WriteLine(\"\");\r\n\r\nConsole.WriteLine(\"Min: {0}, Max: {1}\", tuples.Min, tuples.Max);\r\n<\/pre>\n<p>\uc704 \ucf54\ub4dc\uc758 \uc2e4\ud589 \uacb0\uacfc\ub294 \uc544\ub798\uc640 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p><code>Sorted List<br \/>\n10 100.1<br \/>\n10 1000.1<br \/>\n40 100.4<br \/>\n50 200.5<br \/>\n70 2100.7<br \/>\n80 20.8<\/p>\n<p>Min: (10, 100.1), Max: (80, 20.8)<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C#\uc758 \uc790\ub8cc\uad6c\uc870 \uc911 Key-Value \ucee8\ud14c\uc774\ub108\ub294 Dictionary\uc785\ub2c8\ub2e4. \uacbd\uc6b0\uc5d0 \ub530\ub77c Key\ub85c \uc815\ub82c\ub41c Dictionary\ub294 SortedDictionary \ud074\ub798\uc2a4\ub85c\uc368 C#\uc5d0\uc11c \uae30\ubcf8\uc801\uc73c\ub85c \uc81c\uacf5\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub7f0\ub370, Dictionary\uc774\ubbc0\ub85c Key\uac00 \uc911\ubcf5\ub420 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. \uc911\ubcf5\ub41c \uac12\uc744 \uc815\ub82c\ud574\uc11c \uc800\uc7a5\ud558\uae30 \uc704\ud574\uc11c\ub294 Set \uc790\ub8cc \uad6c\uc870\ub97c \uc774\uc6a9\ud574\uc57c \ud569\ub2c8\ub2e4. \uadf8\ub7f0\ub370, Set\ub294 Key\ub9cc\uc744 \uc800\uc7a5\ud560 \uc218 \uc788\uace0 Value\ub294 \uc800\uc7a5\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. \uc911\ubcf5\ub41c Key\ub97c \ud5c8\uc6a9\ud558\uba74\uc11c, Key\ub85c \uc815\ub82c\ub41c \ucee8\ud14c\uc774\ub108\ub294 \uae30\ubcf8\uc801\uc73c\ub85c C#\uc5d0\uc11c \uc81c\uacf5\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \ud558\uc9c0\ub9cc \ub450\uac1c\uc758 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=5955\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;[C#] \uc911\ubcf5\ub41c Key\ub97c \ud5c8\uc6a9\ud558\uba70, Key\ub85c \uc815\ub82c \ub41c \ud574\uc26c\ub9f5(Dictionary)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118],"tags":[],"class_list":["post-5955","post","type-post","status-publish","format-standard","hentry","category-csharp"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/5955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5955"}],"version-history":[{"count":7,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/5955\/revisions"}],"predecessor-version":[{"id":9551,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/5955\/revisions\/9551"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5955"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}