Hirdetés
Új hozzászólás Aktív témák
-
#74220800
törölt tag
Amúgy a feladatom az lenne, hogy saját kezűleg kell implementalni egy priorityqueque-t, minheap struktúrával,
az alábbi interface segitsegevel:/**
* Manages elements within a priority queue. All Elements in this queue must
* implement the Comparable interface. If a element is requested from this data
* structure the smallest one is returned. If there are multiple smallest
* elements, one of them must be returned.
*/
public class PriorityQueue<T extends Comparable<T>> {
/**
* @param maxElements The maximum number of elements this queue can hold.
*/
public PriorityQueue(int maxElements);
/**
* Add e to the queue.
*
* @param e The element which sould be inserted (at the correct position) into the queue.
* @throws IllegalStateException if the queue is already full
*/
public void add(T e) throws IllegalStateException;
/**
* Returns and removes the smallest element in the queue.
*
* @return the smallest element
* @throws IllegalStateException if the queue is empty
*/
public T pop() throws IllegalStateException;
/**
* Return the current number of elements in the queue.
*
* @return the number of elements
*/
public int size();
}Es nem tudom, hogy milyen classot használhatnék e szerint az adatok belső menedzselésére.
A baj az, hogy a beepitett java PriorityQueue is minheapet használ.LinkedList<E> ill. ArrayList<E> szeretnek használni hozza.
Vagy a fenti feladat azt jelenti, hogy a bepitett PriorityQueue-hoz felülirom a pop() es add() metódusokat?
De akkor meg nem tudok indexeket hasznalni, és az algoritmus alapján szerintem mindenképpen olyan kell, ami indexelhető. Nem tudom ...
-
#74220800
törölt tag
Na várj:
Szóval azt mondod, hogy ha a classom első sorában csak az arraylistet húzom be, mondjuk így:
import java.util.ArrayList;
és utána így példányosítok:
PriorityQueue<Integer> intMyQueue = new PriorityQueue<Integer>(10);
Akkor az én classom lesz meghívva és nem a beépített?
Új hozzászólás Aktív témák
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- LOQ 15AHP10 15.6" FHD IPS Ryzen 7 250 RTX 5060 16GB 512GB NVMe magyar vbill gar
- Lenovo Legion 5 15IAH7H - 32GB, 1TB, 12700H, 3070 Ti, 165Hz WQHD
- Cyborg 15 A13VF 15.6" FHD IPS i7-13620H RTX 4060 16GB 512GB NVMe gar
- Cyborg 15 A13VF 15.6" FHD IPS i7-13620H RTX 4060 16GB 512GB NVMe gar
- Dell - U2715H / 27" / UHD: 2560x1440 / 60 Hz / IPS
- MacBook, Apple M1 / M2 kompatibilis dokkolók, DisplayLink 4K, USB-C, Type-C
- Apple iPhone XR / 64GB / Kártyafüggetlen /12Hó Garancia / Akku: 91%
- 152 - Lenovo LOQ (15IRH8) - Intel Core i5-12450H, RTX 4060 (ELKELT)
- Telefon felvásárlás!! iPhone X/iPhone Xs/iPhone XR/iPhone Xs Max
- Samsung Galaxy S22 / 8/128GB / Kártyafüggetlen / 12Hó Garancia
Állásajánlatok
Cég: Central PC számítógép és laptop szerviz - Pécs
Város: Pécs
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest



