mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
Introduce get_dom_node_list_index() to lookup the index of a node in a list
This commit is contained in:
parent
d36b2d8a36
commit
1347678988
@ -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 *
|
||||
|
@ -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. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user