Ú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?:))
- Bomba Ár! Lenovo IdeaPad Flex 5 Ryzen 3 5300U I 4GB I 128SSD I 14" FHD Touch I W11 I Cam I Garancia!
- Bomba ár! HP ProBook X360 435 G7 - Ryzen 3/5 I 8GB I 256SSD I 13,3" FHD Touch I W11 I Cam I Gari!
- Bomba ár! Lenovo ThinkPad X13 G1 - AMD Ryzen 5 PRO I 8GB I 256SSD I 13,3" FHD I Cam I W11 I Gari!
- Bomba Ár! Lenovo ThinkPad E14 G2 AMD - Ryzen 5 I 8GB I 256SSD I 14" FHD I HDMI I W11 I Gari
- Bomba ár! Lenovo ThinkPad T14s G1 - i7-10G I 16GB I 512GB SSD I 14" FHD Touch I Cam I W11 I Gari!
- Azonnali készpénzes félkonfig / félgép felvásárlás személyesen / csomagküldéssel korrekt áron
- ÁRGARANCIA!Épített KomPhone i5 14400F 32/64GB RAM RTX 5060 Ti 8GB GAMER PC termékbeszámítással
- Lenovo ThinkPad T14 Gen1 Ryzen5 4650U
- Asus ROG Zephyrus G14 - 14"2.8K OLED 120Hz - Ryzen 9 8945HS - 16GB - 1TB - RTX 4060 -2,5 év garancia
- 18 éve! Billentyűzet magyarítás magyarosítás. Festés vagy lézerezés és egyebek! 3 lehetőség is van.
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest