www.fatihkabakci.com

Personal Website and Computer Science TUR EN

JAVA ESLEMELER(MAP)

Last update: 10/3/2014 6:31:00 PM

Yazan:Fatih KABAKCI

Java util paketi içerisinde tanımlanan ve JCF içinde anılsada esasen bir koleksiyon arabirimi olmayan eşlemeler(map) anahtar/değer çifti saklayan veri yapılarıdır. Map 'ler elemanlarına(Entry) Set ve Collection koleksiyonları tarafından erişilmesine imkan sunan metotlar sağladığı için JCF (Java Collection Framework) içerisinde anılmaktadır.

Interface

  1. Map, eşlemelerin en temel arabirimidir.
  2. Map.Entry, Map 'lerin her bir üyesi (değer,anahtar) birer Entry olarak adlandırılır.
  3. NavigableMap, Map içindeki elemanların birbirleri arasında büyüklük-küçüklük ilişkilerini kapsar.
  4. SortedMap, Map 'in içindeki anahtarları sıralı bir şekilde depolar.

Bir Map olan HashMap Sınıfı

Map içerisinde en sık kullanılan sınıf HashMap tir. HashMap 'ler anahtar/değer çiftleri ile veri saklayan sınıflardır. En önemli özelliği anahtara göre verileri saklaması dışında, bu verileri saklarken ve kullanırken de hızlı çalışmasıdır. HashMap Hash tablosu kullanarak verileri depolar.

Map i anlamak adına aşağıdaki örneği inceleyelim. 3 adet üyeden oluşan bir topluluğumuzun olduğunu varsayalım. Amacımız bu üyeleri topluluğa ekleyerek onları tanımlamak olacaktır. Öncelikle bu problemi Java da standart yöntemler ile deneyecek olursak aşağıdaki gibi bir kod yapısı ortaya çıkar.




Yukarıdaki program ortalama 70-100 satır arasında yazılırken, oluşturduğu çıktı aşağıdaki gibidir.


Şayet aynı program bir anahtar/değer çifti saklayan HashMap ile gerçeklenirse aşağıdaki 3-4 satırlık bir Java programı oluşacaktır.


Bu programın oluşturduğu çıktı ise aşağıda verilmektedir.



Map 'lerin ağaç yapısı kullanılarak artan sırada tutulan veri yapıları TreeMap 'ler, Enum tipli verileri tutan EnumMap 'ler HashMap 'lerin verileri sıralı bir şekilde tutan LinkedHashMap ' lerde benzer çalışan diğer Map sınıflarıdır.
There has been no comment yet

Name:


Question/Comment
   Please verify the image




The Topics in Computer Science

Search this site for





 

Software & Algorithms

icon

In mathematics and computer science, an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning.

Programming Languages

icon

A programming language is a formal constructed language designed to communicate instructions to a machine, particularly a computer. It can be used to create programs to control the behavior of a machine. Java,C, C++,C#

Database

icon

A database is an organized collection of data. The data are typically organized to model aspects of reality in a way that supports processes requiring information.

Hardware

icon

Computer hardware is the collection of physical elements that constitutes a computer system. Computer hardware refers to the physical parts or components of a computer such as the monitor, memory, cpu.

Web Technologies

icon

Web development is a broad term for the work involved in developing a web site for the Internet or an intranet. Html,Css,JavaScript,ASP.Net,PHP are one of the most popular technologies. J2EE,Spring Boot, Servlet, JSP,JSF, ASP

Mobile Technologies

icon

Mobile application development is the process by which application software is developed for low-power handheld devices, such as personal digital assistants, enterprise digital assistants or mobile phones. J2ME

Network

icon

A computer network or data network is a telecommunications network that allows computers to exchange data. In computer networks, networked computing devices pass data to each other along data connections.

Operating Systems

icon

An operating system is software that manages computer hardware and software resources and provides common services for computer programs. The OS is an essential component of the system software in a computer system. Linux,Windows

Computer Science

icon

Computer science is the scientific and practical approach to computation and its applications.A computer scientist specializes in the theory of computation and the design of computational systems.