1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-28 03:06:20 -04:00

Introduce get_dom_node_list_index() to lookup the index of a node in a list

This commit is contained in:
Jonas Fonseca 2005-12-25 03:46:01 +01:00 committed by Jonas Fonseca
parent d36b2d8a36
commit 1347678988
2 changed files with 22 additions and 0 deletions

View File

@ -228,6 +228,23 @@ get_dom_node_map_entry(struct dom_node_list *list, enum dom_node_type type,
return dom_node_list_bsearch(&search, list);
}
int
get_dom_node_list_index(struct dom_node *parent, struct dom_node *node)
{
struct dom_node_list **list = get_dom_node_list(parent, node);
struct dom_node *entry;
int i;
if (!list) return -1;
foreach_dom_node (*list, entry, i) {
if (entry == node)
return i;
}
return -1;
}
/* Nodes */
struct dom_node *

View File

@ -233,6 +233,11 @@ add_to_dom_node_list(struct dom_node_list **list_ptr,
void done_dom_node_list(struct dom_node_list *list);
/* Returns the position or index where the @node has been inserted into the
* 'default' list of the @parent node. (Default means use get_dom_node_list()
* to acquire the list to search in. Returns -1, if the node is not found. */
int get_dom_node_list_index(struct dom_node *parent, struct dom_node *node);
/* Returns the position or index where the @node should be inserted into the
* node @list in order to the list to be alphabetically sorted. Assumes that
* @list is already sorted properly. */