본문 바로가기
Coding/Java

[JAVA] Collections framework (array, list, set...)

by Gofo 2021. 2. 19.

Collection, Collections framework

Collection

Vector class처럼 객체의 집단을 표현하기 위한 객체이다.

쉽게말해 데이터의 집합을 표현하는 객체이다.

 

Collections framework

이러한 여러 collections들을 표현하고 관리하기 위해 표준화된 구조이다.

이는 동작의 효율을 높이고 프로그래밍의 수고로움을 덜어준다.

 


Collections framework의 장점

요약하자면 프로그램의 동작 효율성을 높이고, 프로그래밍을 쉽게 도와주는 기능을 한다.

장점 = High performance + Low programming effort 인 셈이다.

 

  • 프로그래밍의 용이함 (Reduces programming effort)
    • 데이터 구조(data structure)과 알고리즘을 제공한다.
    • 매번 관련한 구현 코드를 작성할 필요가 없어진다.
  • 높은 퍼포먼스 (Increases performance)
    • 데이터 구조와 알고리즘의 high-performance implementations을 제공한다.
    • 각 인터페이스의 다양한 implementation은 상호 호환이 가능하기 때문에 implementaions을 바꾸면서 프로그램이 동작할 수 있다.
  • API 간 상호 운용성 (Provides interoperability between unrelated APIs)
    • collections 처리에 있어서 공통된 언어를 사용한다. 이로 인해 관련없는 API 간에 상호 운용이 가능하다.
  • API들을 학습하는데 필요한 노력의 감소 (Reduces the effort required to learn APIs)
    • multiple ad hoc collection API을 학습하면 된다.
  • API을 설계하고 실행하는데 드는 노력의 감소 (Reduces the effort required to design and implement APIs)
    • ad hoc collections API을 작성할 필요가 없다. 이용만 하면 된다.
  • SW 재사용 용이 (Fosters software reuse)
    • Collections과 알고리즘에 관한 표준화된 인터페이스를 제공한다.

 


Collections framework 구성

  • Collection interfaces
    • Represent different types of collections, such as sets, lists, and maps.
    • These interfaces form the basis of the framework.
  • General-purpose implementations
    • Primary implementations of the collection interfaces.
  • Legacy implementations
    • The collection classes from earlier releases, Vector and Hashtable, were retrofitted to implement the collection interfaces.
  • Special-purpose implementations
    • Implementations designed for use in special situations.
    • These implementations display nonstandard performance characteristics, usage restrictions, or behavior.
  • Concurrent implementations
    • Implementations designed for highly concurrent use.
  • Wrapper implementations
    • Add functionality, such as synchronization, to other implementations.
  • Convenience implementations
    • High-performance "mini-implementations" of the collection interfaces.
  • Abstract implementations
    • Partial implementations of the collection interfaces to facilitate custom implementations.
  • Algorithms
    • Static methods that perform useful functions on collections, such as sorting a list.
  • Infrastructure
    • Interfaces that provide essential support for the collection interfaces.
  • Array Utilities
    • Utility functions for arrays of primitive types and reference objects.
    • Not, strictly speaking, a part of the collections framework, this feature was added to the Java platform at the same time as the collections framework and relies on some of the same infrastructure.

 


Collection Interface

크게 두 개의 그룹으로 나뉘는데, 두 그룹은 구조상의 차이를 가지고 있다.

  • java.util.Collection : 일반적인 인터페이스이다.
  • java.util.Map : collection으로 다뤄질 수 있게 하는 collection-view operations을 가진다.

 

Collection의 하위

 

Map의 하위

 

주요 인터페이스별 클래스

Interface Hash Table Resizable Array Balanced Tree Linked List Hash Table + Linked List
Set HashSet   TreeSet   LinkedHashSet
List   ArrayList   LinkedList  
Deque   ArrayDeque   LinkedList  
Map HashMap   TreeMap   LinkedHashMap

참고

Java collection framework oracle docs
https://docs.oracle.com/javase/8/docs/technotes/guides/collections/index.html

Java collection framework (TCP School)
http://www.tcpschool.com/java/java_collectionFramework_concept

 

'Coding > Java' 카테고리의 다른 글

[Java] 자바 동작 과정  (0) 2024.04.01
[JAVA] 버전에 따른 주요 기능들 (SE8~SE20)  (0) 2024.03.27

댓글