Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
a0529f24
Commit
a0529f24
authored
26 years ago
by
Fredrik Hübinette (Hubbe)
Browse files
Options
Downloads
Patches
Plain Diff
now uses heapsort
Rev: src/fsort_template.h:1.5
parent
f484d3c2
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fsort_template.h
+45
-53
45 additions, 53 deletions
src/fsort_template.h
with
45 additions
and
53 deletions
src/fsort_template.h
+
45
−
53
View file @
a0529f24
/*
/*
* $Id: fsort_template.h,v 1.
4
199
8
/04/
27 22:33:17
hubbe Exp $
* $Id: fsort_template.h,v 1.
5
199
9
/04/
30 07:25:42
hubbe Exp $
*/
*/
#ifndef SWAP
#ifndef SWAP
...
@@ -16,6 +16,9 @@
...
@@ -16,6 +16,9 @@
#define DEC(X) X=STEP(X,-1)
#define DEC(X) X=STEP(X,-1)
#define SIZE ((long)(char *)STEP((TYPE *)0,1))
#define SIZE ((long)(char *)STEP((TYPE *)0,1))
#define PARENT(X) (((X)-1)>>1)
#define CHILD1(X) (((X)<<1)+1)
static
void
ID
(
register
TYPE
*
bas
,
static
void
ID
(
register
TYPE
*
bas
,
register
TYPE
*
last
register
TYPE
*
last
#ifdef EXTRA_ARGS
#ifdef EXTRA_ARGS
...
@@ -26,67 +29,56 @@ static void ID(register TYPE *bas,
...
@@ -26,67 +29,56 @@ static void ID(register TYPE *bas,
#endif
#endif
)
)
{
{
register
TYPE
*
a
,
*
b
,
tmp
;
register
TYPE
tmp
;
if
(
bas
>=
last
)
return
;
long
howmany
,
x
,
y
,
z
;
a
=
STEP
(
bas
,
1
);
#ifdef PIKE_DEBUG
if
(
a
==
last
)
extern
int
d_flag
;
{
#endif
if
(
CMP
(
bas
,
last
)
>
0
)
SWAP
(
bas
,
last
);
}
else
{
howmany
=
((((
char
*
)
last
)
-
((
char
*
)
bas
))
/
SIZE
)
+
1
;
b
=
STEP
(
bas
,((((
char
*
)
last
)
-
((
char
*
)
bas
))
/
SIZE
)
>>
1
);
if
(
howmany
<
2
)
return
;
SWAP
(
bas
,
b
);
b
=
last
;
for
(
x
=
PARENT
(
howmany
-
1
);
x
>=
0
;
x
--
)
while
(
a
<
b
)
{
#if 1
while
(
a
<
b
)
{
{
y
=
x
;
while
(
1
)
while
(
1
)
{
{
if
(
a
<=
b
&&
CMP
(
a
,
bas
)
<=
0
)
z
=
CHILD1
(
y
);
INC
(
a
);
if
(
z
>=
howmany
)
break
;
else
if
(
z
+
1
<
howmany
&&
CMP
(
STEP
(
bas
,
z
),
STEP
(
bas
,
z
+
1
))
<=
0
)
z
++
;
{
if
(
CMP
(
STEP
(
bas
,
y
),
STEP
(
bas
,
z
))
>
0
)
break
;
while
(
a
<
b
&&
CMP
(
bas
,
b
)
<=
0
)
DEC
(
b
);
SWAP
(
STEP
(
bas
,
y
),
STEP
(
bas
,
z
));
break
;
y
=
z
;
}
if
(
a
<
b
&&
CMP
(
bas
,
b
)
<=
0
)
DEC
(
b
);
else
{
while
(
a
<=
b
&&
CMP
(
a
,
bas
)
<=
0
)
INC
(
a
);
break
;
}
}
}
}
if
(
a
<
b
)
for
(
x
=
howmany
-
1
;
x
;
x
--
)
{
{
SWAP
(
a
,
b
);
SWAP
(
STEP
(
bas
,
x
),
bas
);
INC
(
a
);
y
=
0
;
if
(
b
>
STEP
(
a
,
1
))
DEC
(
b
);
while
(
1
)
}
}
#else
while
(
a
<=
b
&&
CMP
(
a
,
bas
)
<
0
)
INC
(
a
);
while
(
a
<
b
&&
CMP
(
bas
,
b
)
<
0
)
DEC
(
b
);
if
(
a
<
b
)
{
{
SWAP
(
a
,
b
);
z
=
CHILD1
(
y
);
INC
(
a
);
if
(
z
>=
x
)
break
;
if
(
b
>
STEP
(
a
,
1
))
DEC
(
b
);
if
(
z
+
1
<
x
&&
CMP
(
STEP
(
bas
,
z
),
STEP
(
bas
,
z
+
1
))
<=
0
)
z
++
;
if
(
CMP
(
STEP
(
bas
,
y
),
STEP
(
bas
,
z
))
>
0
)
break
;
SWAP
(
STEP
(
bas
,
y
),
STEP
(
bas
,
z
));
y
=
z
;
}
}
#endif
}
DEC
(
a
);
SWAP
(
a
,
bas
);
DEC
(
a
);
ID
(
bas
,
a
XARGS
);
ID
(
b
,
last
XARGS
);
}
}
#ifdef PIKE_DEBUG
if
(
d_flag
>
1
)
for
(
x
=
howmany
-
1
;
x
;
x
--
)
if
(
CMP
(
STEP
(
bas
,
x
-
1
),
STEP
(
bas
,
x
)
)
>
0
)
fatal
(
"Sorting failed!
\n
"
);
#endif
}
}
#undef INC
#undef INC
#undef DEC
#undef DEC
#undef PARENT
#undef CHILD1
#ifdef UNDEF_XARGS
#ifdef UNDEF_XARGS
#undef XARGS
#undef XARGS
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment