rb_link_node(&sn->rb_node, parent, p);
        rb_insert_color(&sn->rb_node, &self->entries);
+       ++self->nr_entries;
 
        return 0;
 }
        struct strlist *self = malloc(sizeof(*self));
 
        if (self != NULL) {
-               self->entries = RB_ROOT;
-               self->dupstr = dupstr;
+               self->entries    = RB_ROOT;
+               self->dupstr     = dupstr;
+               self->nr_entries = 0;
                if (slist && strlist__parse_list(self, slist) != 0)
                        goto out_error;
        }
                free(self);
        }
 }
+
+struct str_node *strlist__entry(const struct strlist *self, unsigned int idx)
+{
+       struct rb_node *nd;
+
+       for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) {
+               struct str_node *pos = rb_entry(nd, struct str_node, rb_node);
+
+               if (!idx--)
+                       return pos;
+       }
+
+       return NULL;
+}
 
 
 struct strlist {
        struct rb_root entries;
-       bool dupstr;
+       unsigned int   nr_entries;
+       bool           dupstr;
 };
 
 struct strlist *strlist__new(bool dupstr, const char *slist);
 int strlist__load(struct strlist *self, const char *filename);
 int strlist__add(struct strlist *self, const char *str);
 
+struct str_node *strlist__entry(const struct strlist *self, unsigned int idx);
 bool strlist__has_entry(struct strlist *self, const char *entry);
 
 static inline bool strlist__empty(const struct strlist *self)
 {
-       return rb_first(&self->entries) == NULL;
+       return self->nr_entries == 0;
+}
+
+static inline unsigned int strlist__nr_entries(const struct strlist *self)
+{
+       return self->nr_entries;
 }
 
 int strlist__parse_list(struct strlist *self, const char *s);