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
072e8c0f
Commit
072e8c0f
authored
Jan 24, 2011
by
Michael Beck
Browse files
Switch pqueue to size_t.
[r28267]
parent
9c359401
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/libfirm/adt/pqueue.h
View file @
072e8c0f
/*
* Copyright (C) 1995-20
08
University of Karlsruhe. All right reserved.
* Copyright (C) 1995-20
11
University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
...
...
@@ -64,7 +64,7 @@ FIRM_API void *pqueue_pop_front(pqueue_t *q);
* @param q The priority queue.
* @return The length of the queue.
*/
FIRM_API
in
t
pqueue_length
(
const
pqueue_t
*
q
);
FIRM_API
size_
t
pqueue_length
(
const
pqueue_t
*
q
);
/**
* Returns true if queue is empty.
...
...
ir/adt/pqueue.c
View file @
072e8c0f
/*
* Copyright (C) 1995-20
08
University of Karlsruhe. All right reserved.
* Copyright (C) 1995-20
11
University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
...
...
@@ -59,13 +59,13 @@ struct pqueue_t {
* Enforces the heap characteristics if the queue
* starting from element at position @p pos.
*/
static
void
pqueue_heapify
(
pqueue_t
*
q
,
unsigned
pos
)
static
void
pqueue_heapify
(
pqueue_t
*
q
,
size_t
pos
)
{
unsigned
len
=
ARR_LEN
(
q
->
elems
);
size_t
len
=
ARR_LEN
(
q
->
elems
);
while
(
pos
*
2
<
len
)
{
pqueue_el_t
tmp
;
unsigned
exchange
=
pos
;
size_t
exchange
=
pos
;
if
(
q
->
elems
[
exchange
].
priority
<
q
->
elems
[
pos
*
2
].
priority
)
{
exchange
=
pos
*
2
;
...
...
@@ -90,7 +90,7 @@ static void pqueue_heapify(pqueue_t *q, unsigned pos)
/**
* Sifts up a newly inserted element at position @p pos.
*/
static
void
pqueue_sift_up
(
pqueue_t
*
q
,
unsigned
pos
)
static
void
pqueue_sift_up
(
pqueue_t
*
q
,
size_t
pos
)
{
while
(
q
->
elems
[
pos
].
priority
>
q
->
elems
[
pos
/
2
].
priority
)
{
pqueue_el_t
tmp
;
...
...
@@ -137,8 +137,8 @@ void *pqueue_pop_front(pqueue_t *q)
ARR_SHRINKLEN
(
q
->
elems
,
0
);
return
q
->
elems
[
0
].
data
;
default:
{
void
*
data
=
q
->
elems
[
0
].
data
;
int
len
=
ARR_LEN
(
q
->
elems
)
-
1
;
void
*
data
=
q
->
elems
[
0
].
data
;
size_t
len
=
ARR_LEN
(
q
->
elems
)
-
1
;
q
->
elems
[
0
]
=
q
->
elems
[
len
];
ARR_SHRINKLEN
(
q
->
elems
,
len
);
...
...
@@ -149,7 +149,7 @@ void *pqueue_pop_front(pqueue_t *q)
}
}
in
t
pqueue_length
(
const
pqueue_t
*
q
)
size_
t
pqueue_length
(
const
pqueue_t
*
q
)
{
return
ARR_LEN
(
q
->
elems
);
}
...
...
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