π™Œπ™ͺπ™šπ™ͺπ™š

uuuouuoΒ·2022λ…„ 7μ›” 22일
0
post-thumbnail

πŸ“– 큐


  • μ‚½μž…κ³Ό μ‚­μ œμ˜ μœ„μΉ˜κ°€ μ œν•œμ μΈ 자료ꡬ쑰
    • μ‚½μž…μ€ λ’€μ—μ„œλ§Œ, μ‚­μ œλŠ” μ•žμ—μ„œλ§Œ 이루어짐
  • 큐에 μ‚½μž…ν•œ μˆœμ„œλŒ€λ‘œ μ›μ†Œ μ €μž₯
  • κ°€μž₯ λ¨Όμ € μ‚½μž…λœ μ›μ†ŒλŠ” κ°€μž₯ λ¨Όμ € μ‚­μ œ : μ„ μž…μ„ μΆœ(FIFO)
  • μ‹œκ°„ λ³΅μž‘λ„
    • μ‚½μž…, μ‚­μ œ : O(1)
    • 탐색 : O(n)

πŸ’¬ 큐의 μ£Όμš” λ©”μ†Œλ“œ


  • μ„ μ–Έ : Queue< Element > q = new LinkedList<>();

    λ©”μ†Œλ“œμ„€λͺ…
    boolean add(E e)μ „λ‹¬λœ Element μ‚½μž…
    E element()Elementλ₯Ό λ°˜ν™˜ν•˜μ§€λ§Œ μ œκ±°λŠ” μ•ˆλ¨
    boolean offer(E e)μ „λ‹¬λœ Element μ‚½μž…
    E peek()κ°€μž₯ λ§ˆμ§€λ§‰ μ›μ†Œ 확인 (μ—†μœΌλ©΄ null λ°˜ν™˜)
    E poll()κ°€μž₯ μ•ž μ›μ†Œ λ°˜ν™˜ ν›„ 제거 (μ—†μœΌλ©΄ null λ°˜ν™˜)
    E remove()κ°€μž₯ μ•ž μ›μ†Œ λ°˜ν™˜ ν›„ 제거
  • 이 외에도 Collectionμ—μ„œ μ œκ³΅ν•˜λŠ” λ©”μ†Œλ“œ μ‚¬μš© κ°€λŠ₯
    addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray

0개의 λŒ“κΈ€