MrLamont.com

  • Home
  • Student Information
  • ICS3CI-01
    • Marks
    • Pursuing a Programming Career >
      • Post-Secondary Education
      • Assignment
    • Unit 1 - Basic Drawing >
      • The Coordinate System
      • Basic Drawing Commands
      • Adding Colour
    • Unit 2 - Basic Animations >
      • Flowcharting
      • If, Else if, and Else Statements
    • Unit 3: Human Interaction
    • Unit 4: Creating Methods
    • Unit 5: For Loops >
      • Sample drawings to Try
    • Unit 6: Arrays
    • Final Project (30%)
    • EXTRA - Classes and Objects
  • ICS3UI
    • Hand In List
    • GitHub Info
    • Self Evaluation
    • Marks
    • Classroom Repository
    • Unit 2: Making Decisions - If and While >
      • Branching With If
      • Using While Loops
      • Nesting Statements
      • Flowcharting
      • Exercise 2
      • Quiz 2
    • Unit 3: Counting Loops and More Decisions >
      • Variables
      • The For Loop
      • Exercise 3
      • Quiz 3
    • Unit 4: Basic Input/Output >
      • Your First Program
      • Output to the Screen
      • Getting User Input
      • Exercise 4 - Input, Output, Variables
    • Unit 5 - Fun with Java Strings >
      • String Methods
      • Exercise 5 - Translator
    • Unit 6 - Java Methods >
      • Anatomy of a Method
      • Creating Your Own Methods
      • Exercise 6 - Methods
    • Unit 7 - 1D Arrays >
      • Arrays
      • Exercise 7 - Arrays
    • Unit 8 - 2D Graphics >
      • Flappy Bird Assets
      • Basic Game Class
      • The Graphics Class
      • Get Things Moving!
      • Exercise 8 - Clown Face
    • Final Project (30%)
  • Interesting Links
    • Programming Club
    • Game Design
    • Game Programming
    • How it Works
  • Home
  • Student Information
  • ICS3CI-01
    • Marks
    • Pursuing a Programming Career >
      • Post-Secondary Education
      • Assignment
    • Unit 1 - Basic Drawing >
      • The Coordinate System
      • Basic Drawing Commands
      • Adding Colour
    • Unit 2 - Basic Animations >
      • Flowcharting
      • If, Else if, and Else Statements
    • Unit 3: Human Interaction
    • Unit 4: Creating Methods
    • Unit 5: For Loops >
      • Sample drawings to Try
    • Unit 6: Arrays
    • Final Project (30%)
    • EXTRA - Classes and Objects
  • ICS3UI
    • Hand In List
    • GitHub Info
    • Self Evaluation
    • Marks
    • Classroom Repository
    • Unit 2: Making Decisions - If and While >
      • Branching With If
      • Using While Loops
      • Nesting Statements
      • Flowcharting
      • Exercise 2
      • Quiz 2
    • Unit 3: Counting Loops and More Decisions >
      • Variables
      • The For Loop
      • Exercise 3
      • Quiz 3
    • Unit 4: Basic Input/Output >
      • Your First Program
      • Output to the Screen
      • Getting User Input
      • Exercise 4 - Input, Output, Variables
    • Unit 5 - Fun with Java Strings >
      • String Methods
      • Exercise 5 - Translator
    • Unit 6 - Java Methods >
      • Anatomy of a Method
      • Creating Your Own Methods
      • Exercise 6 - Methods
    • Unit 7 - 1D Arrays >
      • Arrays
      • Exercise 7 - Arrays
    • Unit 8 - 2D Graphics >
      • Flappy Bird Assets
      • Basic Game Class
      • The Graphics Class
      • Get Things Moving!
      • Exercise 8 - Clown Face
    • Final Project (30%)
  • Interesting Links
    • Programming Club
    • Game Design
    • Game Programming
    • How it Works

ADT Queue

A Queue (pronounced cue) is a list of items but this time when I add something to the list, it is added to the back of the line. When a retrieve an item from the queue, I grab it from the front of the line. This is known as a First-In First-Out (FIFO) data type. Think of it as waiting in line to by tickets. The person who gets to the line first is the first person to get a ticket. Everyone else lines up after them and is called in turn of when they joined the line.

A queue has the following methods:
  • enqueue(Object item)  <-- add an item to the queue
  • dequeue()  <-- retrieve the first item from the queue
  • peek()  <-- take a look at the first item in the queue
  • size()  <-- how many items are in the queue
  • isEmpty()  <-- returns whether the queue is empty or not

Deque Implementation

A deque is a specific implementation that uses a doubley linked list (a list that has a pointer to the next node and the previous node). This means we have direct access to both the front and the back of the list at the same time. This makes it a great implementation to use because all of the operations can be done in O(1) time.
Powered by
✕