문제

I would like a "symbol alphabet" to have a bi-directional map with weak/soft references. Something like an Apache's Common BidiMap (or Guava's BiMap) with a WeakMap-like interface.

A solution would be to use BiMap<WeakReference<K>,V> and once in a while clean-up entries, but it's not optimal. Any suggestions?

도움이 되었습니까?

해결책

If you're up for building a custom implementation, almost certainly the right way to do it will be to build your own custom hash table and maintain a ReferenceQueue that's used to track removals.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top