#Is there a way to make it so that a set or array cannot have two classes instances of same types
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
erm wtf
I dont really understand your question
do you want a data structure that only stores unique objects?
Lets say theres a record named B and a set named A
now I want it soo that only 1 instance of record B can exist in A at a time
use a map
Its like
Theres an interface named ItemModifier which is implemented by many records, all those records are stored in an set but I dont want more than 2 instances of same record existing in set
Map<Class<?>, Object> map```
hmm
each key can only exist once. a hash set is just a hashmap under the hood
I guess
JDK main-line development https://openjdk.org/projects/jdk - openjdk/jdk
Set does not provide the functionality you want. but you can replicate it
thanks :)