Lab04
4th lab at 07.10.2024
Base project
Use project at https://gitlab.vsb.cz/jez04-vyuka/java-efrei/efrei-lab04.git as a base to complete the following tasks.
Import to Eclipse:
- File -> Import... -> project from Git (with smart import) -> Clone URI -> (use above link as URI) -> Next -> Next -> Finish
Open in InteliJ IDEA:
- File -> New -> Project from Version Control... -> (use above link as URL) -> Clone
Use Set without hashcode and equals methods
Create two object of class Hero with same name and same strenght. Try add them into HashSet collection and test if they are inserted and if they are same.
Use Set with equals method base on name
Add equals method only into class Hero. Implement Equals method to test only name of hero.
Create two object of class Hero with same name and different strenght. Try add them into HashSet collection and test if they are inserted and if they are same.
Use Set with Hero with correct hashCode and equals
Add equals and hashcode methods into class Hero. Implement Equals and hashcode method to test both name and strenght of hero.
Create two object of class Hero with same name and same strenght. Try add them into HashSet collection and test if they are inserted and if they are same.
Use Set with Hero with equals and bad hashCode
Add equals and hashcode methods into class Hero. Implement Equals to check equality only of name and hashcode method calculate hashCode base on strenght of hero.
Create two object of class Hero with same name and different strenght. Try add them into HashSet collection and test if they are inserted and if they are same.
Use Set with Hero with equals and constant hashCode
Add equals and hashcode methods into class Hero. Implement Equals to check equality only of name and hashcode method to return some constant instead of calculate some hashcode.
Create two object of class Hero with same name and same strenght. Try add them into HashSet collection and test if they are inserted and if they are same.
Measure performace of HashSet with correct impementation
Add equals and hashcode methods into class Hero. Implement Equals and hashCode correctlly base on name and strenght.
Create 20000 object of class Hero and add them into HashSet and measure duartion.
Measure performace of HashSet with incorrect impementation
Add equals and hashcode methods into class Hero. Implement Equals base on name and strenght and hashCode will return some constant value.
Create 20000 object of class Hero and add them into HashSet and measure duartion.
Measure performace of Lists
Create 500000 object of class Hero and measure duration of:
- add them into end of ArrayList
- add them into end of LinkedList
- insert them into begining of ArrayList
- insert them into begining of LinkedList
Solution
solution can be found in project original project in branche solution