﻿
{"id":6337,"date":"2017-05-22T15:05:33","date_gmt":"2017-05-22T15:05:33","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=6337"},"modified":"2017-05-22T15:05:33","modified_gmt":"2017-05-22T15:05:33","slug":"cta-gostericipointer-gostericiler-ile-dizi-islemleri-viii","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/cta-gostericipointer-gostericiler-ile-dizi-islemleri-viii\/","title":{"rendered":"C#\u2019ta G\u00f6sterici(Pointer) \u2013 G\u00f6stericiler \u0130le Dizi \u0130\u015flemleri \u2013 VIII"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>Bir \u00f6nceki <a href=\"http:\/\/www.gencayyildiz.com\/blog\/cta-gostericipointer-fixed-anahtar-sozcugu-vii\/\" target=\"_blank\" rel=\"noopener noreferrer\">C#\u2019ta G\u00f6sterici(Pointer) \u2013 fixed Anahtar S\u00f6zc\u00fc\u011f\u00fc \u2013 VII<\/a> ba\u015fl\u0131kl\u0131 makalemizde g\u00f6stericilerin i\u015faretledi\u011fi nesnelerin \u00fcye elemanlar\u0131n\u0131n bellek adreslerini Garbage Collector mekanizmas\u0131na kar\u015f\u0131 \u00f6nlem alarak sabitleyen fixed anahtar s\u00f6zc\u00fc\u011f\u00fcn\u00fc incelemi\u015ftik. Bu makalemizde ise g\u00f6stericiler ile dizi i\u015flemlerini ele alaca\u011f\u0131z.<\/p>\n<p>Yukar\u0131da adresini vermi\u015f oldu\u011fum \u00f6nceki i\u00e7eri\u011fimizde vurgulad\u0131\u011f\u0131m gibi s\u0131n\u0131f yap\u0131lar\u0131 managed type(y\u00f6netilen tip) olduklar\u0131ndan dolay\u0131 bellek adreslerini pointerlar ile i\u015faretleyememekteyiz. Bu bilgiye dayanarak diziler \u00fczerinde \u015f\u00f6yle bir muhakemede bulunabiliriz&#8230;<\/p>\n<p>Biliyorsunuz ki, C#&#8217;ta diziler System.Array s\u0131n\u0131f\u0131 t\u00fcr\u00fcnden yap\u0131lard\u0131r. Haliyle managed type kapsam\u0131na girmektedirler. \u0130\u015fte bu y\u00fczden diziler \u00fczerinde pointerlar ile \u00e7al\u0131\u015facaksak fixed anahtar s\u00f6zc\u00fc\u011f\u00fc olmaks\u0131z\u0131n bu i\u015flem pek m\u00fcmk\u00fcn olmayacakt\u0131r.<\/p>\n<p>K\u00e2h fixed ile ilgili dizinin i\u00e7erisindeki de\u011ferlerin bellek adreslerini garbage collector&#8217;a kar\u015f\u0131 sabitleyece\u011fiz k\u00e2h bir ba\u015fka y\u00f6ntem olarakta <em>stackalloc<\/em> keyword\u00fc ile unmanaged type(y\u00f6netilmeyen tip) diziler olu\u015ftururuz. Tabi bu i\u00e7eri\u011fimizde birincil \u00f6nc\u00fcldeki y\u00f6ntemi, yani fixed yap\u0131s\u0131 ile diziler \u00fczerinde pointer \u00e7al\u0131\u015fmas\u0131n\u0131 ele alaca\u011f\u0131z.<\/p>\n<p>\u00d6ncelikle dizilerin fixed keyword\u00fc olmaks\u0131z\u0131n g\u00f6stericilerle kullan\u0131lamayaca\u011f\u0131n\u0131 a\u015fa\u011f\u0131daki ekran g\u00f6r\u00fcnt\u00fcs\u00fcnden g\u00f6rmekteyiz.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6343\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII.png\" alt=\"C#\u2019ta G\u00f6sterici(Pointer) \u2013 G\u00f6stericiler \u0130le Dizi \u0130\u015flemleri \u2013 VIII\" width=\"326\" height=\"80\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII.png 326w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-300x74.png 300w\" sizes=\"auto, (max-width: 326px) 100vw, 326px\" \/><\/a><\/p>\n<p>Halbuki a\u015fa\u011f\u0131daki gibi fixed yap\u0131s\u0131nda g\u00f6stericilerle dizilerde rahatl\u0131kla \u00e7al\u0131\u015fabilmekteyiz.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6345\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-1.png\" alt=\"\" width=\"320\" height=\"130\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-1.png 320w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-1-300x122.png 300w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<p>G\u00f6stericiler ile dizi i\u015flemleri yap\u0131sal olarak bu \u015fekilde kullan\u0131lmaktad\u0131r. Asl\u0131nda konumuzu burada bitirsek yeridir ama <strong><em>&#8220;hoca! dizinin di\u011fer elemanlar\u0131na nas\u0131l eri\u015fece\u011fiz?&#8221;<\/em><\/strong> sorunuzu duyar gibiyim&#8230;<\/p>\n<p>Bu i\u015flem i\u00e7in \u00f6nceki yaz\u0131lar\u0131mdan <a href=\"http:\/\/www.gencayyildiz.com\/blog\/cta-gostericipointer-gostericilerde-aritmatik-islemler-vi\/\" target=\"_blank\" rel=\"noopener noreferrer\">G\u00f6stericilerde Aritmatik \u0130\u015flemler<\/a> ba\u015fl\u0131kl\u0131 i\u00e7eri\u011fimde de\u011findi\u011fim yap\u0131lar\u0131 ve mant\u0131\u011f\u0131 kullanaca\u011f\u0131z.<\/p>\n<p>Tabi o mant\u0131\u011fa gelmeden \u00f6nce dizilerin bellekteki yerle\u015fke d\u00fczenine de\u011finmekte fayda var.<\/p>\n<p>Bir dizi tan\u0131mlad\u0131\u011f\u0131m\u0131z vakit o dizinin eleman say\u0131s\u0131 kadar alan bellekte ard\u0131\u015f\u0131l bir \u015fekilde \u00f6nceden tan\u0131mlanmaktad\u0131r. Haliyle bir dizinin elemanlar\u0131na pointer ile eri\u015fmek istiyorsak algoritmik olarak o dizinin herhangi bir eleman\u0131n\u0131n bellek adresi ile dizinin eleman say\u0131s\u0131 bu i\u015flemi yapabilmemiz i\u00e7in yeterli ba\u011f\u0131nt\u0131y\u0131 bizlere sa\u011flayacakt\u0131r. Yapaca\u011f\u0131m\u0131z algoritmik \u00e7al\u0131\u015fma ile ilgili dizinin elemanlar\u0131n\u0131 i\u015faretleyen g\u00f6stericiye (+1 | -1) ekleyerek di\u011fer elemanlara pointer ile rahatl\u0131kla eri\u015febiliriz. Tabi burada dizinin ilk eleman\u0131n\u0131 baz al\u0131rsak e\u011fer pointera +1 de\u011ferini eklemek i\u015flevsel olarak algoritmam\u0131z\u0131 daha kolay, mant\u0131kl\u0131 ve pratik hale getirecektir.<\/p>\n<p>\u015eimdi a\u015fa\u011f\u0131daki ekran g\u00f6r\u00fcnt\u00fcs\u00fcn\u00fc inceleyiniz.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6352\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-2.png\" alt=\"C#\u2019ta G\u00f6sterici(Pointer) \u2013 G\u00f6stericiler \u0130le Dizi \u0130\u015flemleri \u2013 VIII\" width=\"620\" height=\"174\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-2.png 620w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-2-300x84.png 300w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/a><br \/>\nYukar\u0131daki g\u00f6r\u00fcnt\u00fcde anlatmaya \u00e7al\u0131\u015ft\u0131\u011f\u0131m gibi bir dizinin ilk eleman\u0131 pointer taraf\u0131ndan i\u015faretlenmekte ve sonraki elemanlara for d\u00f6ng\u00fcs\u00fc e\u015fli\u011finde eleman say\u0131s\u0131 kadar d\u00f6n\u00fclerek pointera +1 ekleyerek eri\u015filmektedir. Nihayetinde pointerlarda yap\u0131lan aritmatik i\u015flemler (<strong><span style=\"color: #008000;\"><em>pointer += (de\u011fer) * sizeof(type)<\/em><\/span><\/strong>) ba\u011f\u0131nt\u0131s\u0131na g\u00f6re netice verdi\u011fi i\u00e7in her bir d\u00f6ng\u00fc bir sonraki dizi eleman\u0131n\u0131 getirecektir.<\/p>\n<p>Ayriyetten pointera dizinin referans\u0131n\u0131 direkt olarak verirsek bu tan\u0131mlama dizinin ilk eleman\u0131na tekab\u00fcl edecektir.<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-3.png\" alt=\"C#\u2019ta G\u00f6sterici(Pointer) \u2013 G\u00f6stericiler \u0130le Dizi \u0130\u015flemleri \u2013 VIII\" width=\"782\" height=\"161\" class=\"aligncenter size-full wp-image-6355\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-3.png 782w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-3-300x62.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-3-768x158.png 768w\" sizes=\"auto, (max-width: 782px) 100vw, 782px\" \/><\/a><\/p>\n<p>Dizinin referans\u0131 ile dizinin ilk eleman\u0131n\u0131n bellek adresini a\u015fa\u011f\u0131daki gibi yazd\u0131r\u0131rsak e\u015fit olduklar\u0131n\u0131 g\u00f6receksiniz.<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-4.png\" alt=\"C#\u2019ta G\u00f6sterici(Pointer) \u2013 G\u00f6stericiler \u0130le Dizi \u0130\u015flemleri \u2013 VIII\" width=\"614\" height=\"155\" class=\"aligncenter size-full wp-image-6357\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-4.png 614w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-\u2013-G\u00f6stericiler-\u0130le-Dizi-\u0130\u015flemleri-\u2013-VIII-4-300x76.png 300w\" sizes=\"auto, (max-width: 614px) 100vw, 614px\" \/><\/a><\/p>\n<p>G\u00f6stericiler ile dizi i\u015flemlerini fixed anahtar s\u00f6zc\u00fc\u011f\u00fc kapsam\u0131nda ele alm\u0131\u015f olduk. Bir sonraki makalemizde; g\u00f6stericiler ile dizi i\u015flemlerini, bu i\u00e7eri\u011fimizde de bahsetti\u011fimiz gibi stackalloc anahtar s\u00f6zc\u00fc\u011f\u00fc ile unmanaged type(y\u00f6netilmeyen tip) diziler olu\u015fturarak ele alaca\u011f\u0131z.<\/p>\n<p>O halde g\u00f6r\u00fc\u015fmek \u00fczere diyelim&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, Bir \u00f6nceki C#\u2019ta G\u00f6sterici(Pointer) \u2013 fixed Anahtar S\u00f6zc\u00fc\u011f\u00fc \u2013 VII ba\u015fl\u0131kl\u0131 makalemizde g\u00f6stericilerin i\u015faretledi\u011fi nesnelerin \u00fcye elemanlar\u0131n\u0131n bellek adreslerini Garbage Collector mekanizmas\u0131na kar\u015f\u0131 \u00f6nlem alarak sabitleyen fixed anahtar s\u00f6zc\u00fc\u011f\u00fcn\u00fc incelemi\u015ftik. Bu makalemizde ise&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":3014,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[1790,1791,1799,1744,1793,1797,1798,1795,1794,1796],"class_list":["post-6337","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-sharp-c","tag-c-fixed-anahtar-sozcugu","tag-c-fixed-keyword","tag-c-stackalloc","tag-garbage-collector","tag-managed-type","tag-stackalloc","tag-stackalloc-keyword","tag-unmanaged-type","tag-yonetilen-tip","tag-yonetilmeyen-tip"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/6337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=6337"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/6337\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/3014"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=6337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=6337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=6337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}