Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
d7757e15
Commit
d7757e15
authored
Sep 13, 2006
by
Christian Würdig
Browse files
added find_value and has_value functions
[r8244]
parent
a464ca47
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/adt/plist.c
View file @
d7757e15
...
...
@@ -147,6 +147,28 @@ void plist_insert_after(plist_t* list, plist_element_t* element, void* value) {
++
list
->
element_count
;
}
int
plist_has_value
(
plist_t
*
list
,
void
*
value
)
{
plist_element_t
*
iter
;
for
(
iter
=
plist_first
(
list
);
iter
;
iter
=
plist_element_get_next
(
iter
))
{
if
(
plist_element_get_value
(
iter
)
==
value
)
return
1
;
}
return
0
;
}
plist_element_t
*
plist_find_value
(
plist_t
*
list
,
void
*
value
)
{
plist_element_t
*
iter
;
for
(
iter
=
plist_first
(
list
);
iter
;
iter
=
plist_element_get_next
(
iter
))
{
if
(
plist_element_get_value
(
iter
)
==
value
)
return
iter
;
}
return
NULL
;
}
void
plist_erase
(
plist_t
*
list
,
plist_element_t
*
element
)
{
plist_element_t
*
next_element
=
element
->
next
;
plist_element_t
*
prev_element
=
element
->
prev
;
...
...
ir/adt/plist.h
View file @
d7757e15
...
...
@@ -126,6 +126,22 @@ void plist_insert_before(plist_t *list, plist_element_t *element, void *value);
*/
void
plist_insert_after
(
plist_t
*
list
,
plist_element_t
*
element
,
void
*
value
);
/**
* Checks if list has an element with the given data pointer.
* @param list the list to check
* @param value the data pointer to look for
* @return 1 if element with data pointer found, 0 otherwise
*/
int
plist_has_value
(
plist_t
*
list
,
void
*
value
);
/**
* Tries to find list element associated to the given data pointer.
* @param list the list to check
* @param value the data pointer to look for
* @return The first list element associated to data pointer if found, NULL otherwise
*/
plist_element_t
*
plist_find_value
(
plist_t
*
list
,
void
*
value
);
/**
* Erases the specified element from the pointer list.
* @param list the pointer list from which the element should be erased.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment