#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)

sleek verge
#

title

light ibexBOT
#

<@&987246399047479336> please have a look, thanks.

sleek verge
#

erm wtf

dry stratus
#

I dont really understand your question

#

do you want a data structure that only stores unique objects?

sleek verge
#

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

tight epoch
#

use a map

sleek verge
#

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

tight epoch
#
Map<Class<?>, Object> map```
sleek verge
#

hmm

tight epoch
#

each key can only exist once. a hash set is just a hashmap under the hood

sleek verge
#

I guess

tight epoch
#

Set does not provide the functionality you want. but you can replicate it

sleek verge
#

thanks :)