0

I have a SplayTreeSet in dart and I was wondering wether I could get the position where the object is inserted.

Usually I would know it as length - 1, but since in SplayTreeSet are sorted, I am not sure the item will end up at the end. Is there a way I could get the index upon insertion without looking for it in a second moment?

Fabrizio
  • 1,138
  • 4
  • 18
  • 41
  • do you mean that [SplayTreeSet](https://api.flutter.dev/flutter/dart-collection/SplayTreeSet-class.html)? if so, it does not have `indexOf` method – pskink Dec 14 '22 at 10:14
  • oh, right sorry, I mean retrieving the index manually (not via indexOf). – Fabrizio Dec 14 '22 at 10:20
  • btw what do you need that index for? – pskink Dec 14 '22 at 10:22
  • I want to create a custom constant look-up table which is sorted on one property but hashes a different one. So I am storing a different map to map the values i want to hash to the index of the item in the SplayTreeMap. – Fabrizio Dec 14 '22 at 10:25

0 Answers0