# How to implement a reverse roaring bitmap iterator? (sroar.Bitmap.NewReverseIterator went away?)

**URL:** <https://discuss.dgraph.io/t/how-to-implement-a-reverse-roaring-bitmap-iterator-sroar-bitmap-newreverseiterator-went-away/17901>\
**Category:** Users\
**Tags:** badger\
**Created:** [October 26, 2022, 12:08pm UTC](https://discuss.dgraph.io/t/how-to-implement-a-reverse-roaring-bitmap-iterator-sroar-bitmap-newreverseiterator-went-away/17901 "2022-10-26T12:08:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![decentral1se](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/decentral1se/32/10096_2.png) [@decentral1se](https://discuss.dgraph.io/u/decentral1se)\
**Post date:** [October 26, 2022, 12:08pm UTC](https://discuss.dgraph.io/t/how-to-implement-a-reverse-roaring-bitmap-iterator-sroar-bitmap-newreverseiterator-went-away/17901/1 "2022-10-26T12:08:31Z")

</div>

Hey 👋

Just to increase visibility, I commented on [opt(iterator): Optimise the iterator and introduce range iterators by ahsanbarkati · Pull Request #19 · dgraph-io/sroar · GitHub](https://github.com/dgraph-io/sroar/pull/19#issuecomment-1291887559) but perhaps opening it out on the forum is good.

I’m doing some upgrade work and have some code which made use of `NewReverseIterator()` (from `github.com/dgraph-io/sroar`) which was removed in [opt(iterator): Optimise the iterator and introduce range iterators by ahsanbarkati · Pull Request #19 · dgraph-io/sroar · GitHub](https://github.com/dgraph-io/sroar/pull/19).

I am trying to learn how to write a reverse iterator with the new APIs which are `NewIterator()` and `Next()` as far as I understand. Does anyone have any tips on how to proceed?

The code in question looks more or less like this:

```auto
	if opts.Descending {
		it = resulting.NewReverseIterator()
	} else {
		it = resulting.NewIterator()
	}

	for it.HasNext() {
		v := it.Next()
                ...

```

Thanks!

PS. Sorry if I got the wrong category, I don’t see something that corresponds to `github.com/draph-io/sroar` here on the forum? 🤔

---

<div class="post-metadata">

**Author:** ![decentral1se](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/decentral1se/32/10096_2.png) [@decentral1se](https://discuss.dgraph.io/u/decentral1se)\
**Post date:** [October 26, 2022, 3:32pm UTC](https://discuss.dgraph.io/t/how-to-implement-a-reverse-roaring-bitmap-iterator-sroar-bitmap-newreverseiterator-went-away/17901/2 "2022-10-26T15:32:52Z")

</div>

In the meantime… came up with something in [chore: upgrade go deps by decentral1se · Pull Request #176 · ssbc/go-ssb · GitHub](https://github.com/ssbc/go-ssb/pull/176#issuecomment-1291891411) 👍 Would still love to see a reverse iterator implementation which doesn’t have the additional allocations… afaiu that functionality is lost in that above mentioned PR?
