コンテンツにスキップ

両端キュー

出典: フリー百科事典『ウィキペディア(Wikipedia)』

: double-ended queue: deque1[1]head-tail linked list 

[]


deque  dequeue dequeue 

 Data Structures and Algorithms  dequeue 使

DEQ DQ

[]


FIFOFIFO





使使

[]



操作 C++ Java Perl PHP Python Ruby JavaScript
末尾に要素を追加 push_back offerLast push array_push append push push
先頭に要素を追加 push_front offerFirst unshift array_unshift appendleft unshift unshift
末尾の要素を取出す pop_back pollLast pop array_pop pop pop pop
先頭の要素を取出す pop_front pollFirst shift array_shift popleft shift shift
末尾の要素を調べる back peekLast $_[-1] end <obj>[-1] last <obj>[<obj>.length - 1]
先頭の要素を調べる front peekFirst $_[0] reset <obj>[0] first <obj>[0]

実装[編集]


2使

使 (array deque) //2




[]


C++

Standard Template Library  std::deque 1[2]O(1)O(n)

Java 6

Collections Framework  Deque  ArrayDeque  LinkedList 

Python 2.4/3

collections.deque 

PHP 5.3

SPL extension  SplDoublyLinkedList 使 array_shift/unshift/pop/push 使

[]


O(1)

O(n)O(1)

使[]


使 A-Steal [3]fork (steal)

関連項目[編集]

脚注[編集]

  1. ^ Donald Knuth. The Art of Computer Programming, Volume 1: Fundamental Algorithms, Third Edition. Addison-Wesley, 1997. ISBN 0-201-89683-4. Section 2.2.1: Stacks, Queues, and Deques, pp. 238–243.
  2. ^ スコット・メイヤーズ、『Effective STL STLを効果的に使いこなす50の鉄則』、ピアソン・エデュケーション、2002年、第7章、ISBN 4-89471-410-8
  3. ^ Eitan Frachtenberg, Uwe Schwiegelshohn (2007). Job Scheduling Strategies for Parallel Processing: 12th International Workshop, JSSPP 2006. Springer. ISBN 3540710345  See p.22.

外部リンク[編集]