์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- Kafka
- aws saa ํฉ๊ฒฉ
- aws ์ฟ ํฐ
- redis ํ ์คํธ์ฝ๋
- ํ๋ก๊ทธ๋๋จธ์ค
- docker-compose kafka
- Codedeploy ์ค๋ฅ
- ํ๋ก๊ทธ๋๋จธ์ค ํฉ์นํ์์๊ธ
- ๋ค์ค ์ปจํ ์ด๋
- redis ์กฐํ
- docker compose
- private subnet ec2 ๋ก์ปฌ ์ ์
- ์๋ฐ
- nGrinder
- docker
- s3 log ์ ์ฅ
- ํ์ดํผ๋ฐ์ด์
- ์๋ฒ ํฐ์ง๋ ๋์ปค ์ฌ์คํ
- s3 ์ด๋ฏธ์ง ๋ค์ด๋ก๋
- AWS Certified Solutions Architect - Associate
- docker ps -a
- @RestControllerAdvice
- ํ๋ก๊ทธ๋๋จธ์ค ์ปฌ๋ฌ๋ง๋ถ
- ์ ํจ์ค ์ค์ผ์ค๋ฌ
- Entity
- ์คํํ๋ ๋ฏธ์ค
- s3 ์ด๋ฏธ์ง ์ ์ฅ
- JPA
- prod docker-compose
- ์ ํจ์ค ๋น๋ ์ค๋ฅ
- Today
- Total
๐๐ข๐๐ โ๐๐๐ ๐๐๐ก๐๐ ๐๐๐๐โง
[Java] PriorityQueue ๋ณธ๋ฌธ
[Java] PriorityQueue
๐คRyusun๐ค 2022. 10. 19. 12:25์๋ฐ ์ฐ์ ์์ ํ
์ ํ๋ ๋๊ฐ ๋น ๋ฅธ์์ผ๋ก ์ ๋ ฌ
์๋ก์ด ์ ๋ ฌ๋ฐฉ์์ ์ฌ์ฉํ๊ธฐ์ํด์๋ PriorityQueue๋ฅผ Comparator<>๋ก ์ฌ์ ์ ํด์ผํ๋ค!!
package me.day14.practice.practice02;
import java.util.Comparator;
import java.util.PriorityQueue;
public class Main {
public static void main(String[] args) {
System.out.println("===============================================================================");
System.out.println("\t\t\t\t์ฐ์ ์์ ํ");
System.out.println("===============================================================================");
// ์ฐ์ ์์๊ฐ ์กด์ฌํ๋ Queue (ํ์ ํตํด ๊ตฌํ)
PriorityQueue<Student> priorityQueue = new PriorityQueue (new Comparator<Student>() {
@Override
public int compare(Student o1, Student o2) {
if (Integer.parseInt(o1.getStudentNo()) < Integer.parseInt(o2.getStudentNo())){
return -1;
} else if (Integer.parseInt(o1.getStudentNo()) > Integer.parseInt(o2.getStudentNo())) {
return 1;
} else {
return 0;
}
}
@Override
public boolean equals(Object obj) {
return false;
}
}) {
};
// PriorityQueue Queue์ ์์ ์ถ๊ฐ
priorityQueue.offer(new Student("20212222", "์ด์์ ", 85)); // ์
ํ์ฐ๋: 2021 + ๋ค์ด๊ฐ ์์: 1
priorityQueue.offer(new Student("20211111", "์๋ฐํน", 100)); // ์
ํ์ฐ๋: 2021 + ๋ค์ด๊ฐ ์์: 2
priorityQueue.offer(new Student("20213333", "์ด์ ์ด", 50)); // ์
ํ์ฐ๋: 2021 + ๋ค์ด๊ฐ ์์: 3
priorityQueue.offer(new Student("20171234", "์ดํ
๋ฆฌ", 80)); // ์
ํ์ฐ๋: 2017 + ๋ค์ด๊ฐ ์์: 4
priorityQueue.offer(new Student("20045555", "์ด์ด์", 70)); // ์
ํ์ฐ๋: 2004 + ๋ค์ด๊ฐ ์์: 5
while (!priorityQueue.isEmpty()) {
Student pollStudent = priorityQueue.poll();
System.out.println("pollStudent = " + pollStudent);
System.out.println("priorityQueue = " + priorityQueue);
System.out.println("priorityQueue.size() = " + priorityQueue.size());
System.out.println();
}
System.out.println();
}
}
์ถ๋ ฅ๋ฌธ
===============================================================================
์ฐ์ ์์ ํ
===============================================================================
pollStudent = Student{studentNo='20045555', name='์ด์ด์', score=70}
priorityQueue = [Student{studentNo='20171234', name='์ดํ
๋ฆฌ', score=80}, Student{studentNo='20211111', name='์๋ฐํน', score=100}, Student{studentNo='20213333', name='์ด์ ์ด', score=50}, Student{studentNo='20212222', name='์ด์์ ', score=85}]
priorityQueue.size() = 4
pollStudent = Student{studentNo='20171234', name='์ดํ
๋ฆฌ', score=80}
priorityQueue = [Student{studentNo='20211111', name='์๋ฐํน', score=100}, Student{studentNo='20212222', name='์ด์์ ', score=85}, Student{studentNo='20213333', name='์ด์ ์ด', score=50}]
priorityQueue.size() = 3
pollStudent = Student{studentNo='20211111', name='์๋ฐํน', score=100}
priorityQueue = [Student{studentNo='20212222', name='์ด์์ ', score=85}, Student{studentNo='20213333', name='์ด์ ์ด', score=50}]
priorityQueue.size() = 2
pollStudent = Student{studentNo='20212222', name='์ด์์ ', score=85}
priorityQueue = [Student{studentNo='20213333', name='์ด์ ์ด', score=50}]
priorityQueue.size() = 1
pollStudent = Student{studentNo='20213333', name='์ด์ ์ด', score=50}
priorityQueue = []
priorityQueue.size() = 0
'๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป > ๐๐๐ฏ๐' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Java] Action Tag (0) | 2022.10.28 |
---|---|
[Java] JSP, Directive (0) | 2022.10.27 |
[Java] Generic Method ์ ๋ค๋ฆญ ๋ฉ์๋ (0) | 2022.10.12 |
[Java] ์บก์ํ (0) | 2022.10.07 |
[Java] ๊ฐ์ฒด, ์์ฑ์, ํด๋์ค (0) | 2022.10.07 |