-
Java API 분석__Class Stack개발입문/자료구조 2017. 7. 24. 19:09
Stack
- java.lang.Object
- java.util.AbstractCollection<E>
- java.util.AbstractList<E>
- java.util.Vector<E>
- java.util.Stack<E>
public class Stack<E> extends Vector<E>
The
Stack
class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with five operations that allow a vector to be treated as a stack. The usual push and pop operations are provided, as well as a method to peek at the top item on the stack, a method to test for whether the stack is empty, and a method to search the stack for an item and discover how far it is from the top.When a stack is first created, it contains no items.
A more complete and consistent set of LIFO stack operations is provided by the
Deque
interface and its implementations, which should be used in preference to this class. For example:- Vector 클래스를 상속해서 thread-safe 한
- LIFO 기능을 제공하는 (push, pop) 리스트 구현체
- 하지만 LIFO 기능을 위해서는 thread-unsafe 하지만 빠른 Deque를 쓰는게 더 좋단다.
Method
public E push(E item)
public E pop()
public E peek()
public boolean empty()
public int search(Object o)
1 - based index(distance) from the top of the stack
'개발입문 > 자료구조' 카테고리의 다른 글
Java API 분석__Set, HashSet, TreeSet, LinkedHashSet (0) 2017.07.25 Java API 분석__Class Vector (0) 2017.07.25 Java API 분석__Class ArrayList (0) 2017.07.24 Java API 분석__ Interface List (0) 2017.07.24 Java API 분석__ Interface Collection (0) 2017.07.24