All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.andyshao.data.structure.PriorityQueue Maven / Gradle / Ivy

The newest version!
package com.github.andyshao.data.structure;

import com.github.andyshao.data.structure.Heap.MyHeap;
import com.github.andyshao.lang.Cleanable;

/**
 * 
 * Title:
* Descript:
* Copyright: Copryright(c) Feb 18, 2015
* Encoding:UNIX UTF-8 * * @author Andy.Shao * * @param data */ public interface PriorityQueue extends Cleanable { /** * Default priority queue * @param data type */ public class MyPriorityQueue extends MyHeap implements PriorityQueue { @Override public DATA peek() { return this.tree.size() == 0 ? null : this.tree.get(0); } } /** * GET the top element from the {@link PriorityQueue} and remove it * @return data */ public D extract(); /** * Insert data into the {@link PriorityQueue} * @param data data */ public void insert(D data); /** * Get the top element from the {@link PriorityQueue}, but * do not omit it * @return data */ public D peek(); /** * The size of the {@link PriorityQueue} * @return the size number */ public int size(); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy