Unique enum member values

前端 未结 5 1090
星月不相逢
星月不相逢 2021-01-19 14:32

My problem: I want to specify a 1 to 1 connection between two enums. basically:

enum MyEnum{

    ENUM_VALUE_1,
    ENUM_VALUE_2,
    ENUM_VALUE_3,

}

enum          


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-19 15:23

    Im a bit confused, by your question. Have you considered using HashSet?

    A HashSet can be used to ensure unique values, then simply add the values used in the HashSet if it returns false the value already exists.

提交回复
热议问题