パッケージ library.ds.deque

クラス MyDeque<T>

java.lang.Object
library.ds.deque.MyDeque<T>
型パラメータ:
T - クラスを乗せる
すべての実装されたインタフェース:
Iterable<T>

public final class MyDeque<T> extends Object implements Iterable<T>
ランダムアクセスが可能なDeque viralさんに感謝
関連項目:
  • コンストラクタの概要

    コンストラクタ
    コンストラクタ
    説明
     
    MyDeque(T[] a)
    コンストラクタにint[]を乗せたい場合, 参考までに以下のように書くことができる new Deque(Arrays.stream(a).boxed().toArray(Integer[]::new));
  • メソッドの概要

    修飾子とタイプ
    メソッド
    説明
    final void
    add(T x)
    Dequeの末尾に要素を追加する
    final void
    Dequeの先頭に要素を追加する
    final void
    Dequeの末尾に要素を追加する
    final void
    Dequeを空にする
    final T
    get(int i)
    Deque[i]を返す
    final boolean
    Dequeが空かどうか判定する
    final Iterator<T>
    イテレータ
    final T
    Dequeの先頭の要素を返す
    final T
     
    final T
     
    final T
    Dequeの先頭の要素を削除する
    final T
    Dequeの先頭の要素を削除する
    final T
    Dequeの末尾の要素を削除する
    final void
    Dequeの先頭の要素を削除する
    final void
    Dequeの末尾の要素を削除する
    final void
    set(int i, T x)
    i番目に要素xを代入する
    final int
    Dequeの大きさを返す
    final void
    swap(int a, int b)
    Dequeのa番目とb番目にある要素を入れ替える
    final String
    出力するために必要

    クラスから継承されたメソッド java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    インタフェースから継承されたメソッド java.lang.Iterable

    forEach, spliterator
  • コンストラクタの詳細

    • MyDeque

      public MyDeque()
    • MyDeque

      public MyDeque(T[] a)
      コンストラクタにint[]を乗せたい場合, 参考までに以下のように書くことができる new Deque(Arrays.stream(a).boxed().toArray(Integer[]::new));
      パラメータ:
      a - クラスTの配列
  • メソッドの詳細

    • isEmpty

      public final boolean isEmpty()
      Dequeが空かどうか判定する
      戻り値:
      Deque.size() == 0
    • size

      public final int size()
      Dequeの大きさを返す
      戻り値:
      Dequeの大きさ
    • addFirst

      public final void addFirst(T x)
      Dequeの先頭に要素を追加する
      パラメータ:
      x -
    • addLast

      public final void addLast(T x)
      Dequeの末尾に要素を追加する
      パラメータ:
      x -
    • removeFirst

      public final void removeFirst()
      Dequeの先頭の要素を削除する
    • removeLast

      public final void removeLast()
      Dequeの末尾の要素を削除する
    • pollFirst

      public final T pollFirst()
      Dequeの先頭の要素を削除する
      戻り値:
      Dequeの先頭にあった要素
    • pollLast

      public final T pollLast()
      Dequeの末尾の要素を削除する
      戻り値:
      Dequeの末尾にあった要素
    • peekFirst

      public final T peekFirst()
      戻り値:
      Dequeの先頭にある要素
    • peekLast

      public final T peekLast()
      戻り値:
      Dequeの末尾にある要素
    • get

      public final T get(int i)
      Deque[i]を返す
      パラメータ:
      i - インデックス
      戻り値:
      Dequeのi番目に格納されている要素
    • set

      public final void set(int i, T x)
      i番目に要素xを代入する
      パラメータ:
      i - インデックス
      x - 要素
    • add

      public final void add(T x)
      Dequeの末尾に要素を追加する
      関連項目:
    • poll

      public final T poll()
      Dequeの先頭の要素を削除する
      関連項目:
    • peek

      public final T peek()
      Dequeの先頭の要素を返す
      関連項目:
    • swap

      public final void swap(int a, int b)
      Dequeのa番目とb番目にある要素を入れ替える
      パラメータ:
      a - インデックス
      b - インデックス
    • clear

      public final void clear()
      Dequeを空にする
    • toString

      public final String toString()
      出力するために必要
      オーバーライド:
      toString クラス内 Object
    • iterator

      public final Iterator<T> iterator()
      イテレータ
      定義:
      iterator インタフェース内 Iterable<T>