Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
36d8c000
Commit
36d8c000
authored
Nov 06, 2012
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly improved cut computation.
parent
5ed242ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
1 deletions
+85
-1
src/map/if/ifCut.c
+85
-1
No files found.
src/map/if/ifCut.c
View file @
36d8c000
...
...
@@ -145,7 +145,7 @@ int If_CutFilter( If_Set_t * pCutSet, If_Cut_t * pCut )
SeeAlso []
***********************************************************************/
static
inline
int
If_CutMergeOrdered
(
If_Cut_t
*
pC0
,
If_Cut_t
*
pC1
,
If_Cut_t
*
pC
)
static
inline
int
If_CutMergeOrdered
Old
(
If_Cut_t
*
pC0
,
If_Cut_t
*
pC1
,
If_Cut_t
*
pC
)
{
int
i
,
k
,
c
;
assert
(
pC0
->
nLeaves
>=
pC1
->
nLeaves
);
...
...
@@ -224,6 +224,90 @@ static inline int If_CutMergeOrdered( If_Cut_t * pC0, If_Cut_t * pC1, If_Cut_t *
Synopsis [Merges two cuts.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static
inline
int
If_CutMergeOrdered
(
If_Cut_t
*
pC0
,
If_Cut_t
*
pC1
,
If_Cut_t
*
pC
)
{
int
nLimit
=
pC0
->
nLimit
;
int
nSizeC0
=
pC0
->
nLeaves
;
int
nSizeC1
=
pC1
->
nLeaves
;
int
i
,
k
,
c
;
assert
(
nSizeC0
>=
nSizeC1
);
// the case when one of the cuts is the largest
if
(
nSizeC0
==
nLimit
)
{
// the case of the largest cut sizes
if
(
nSizeC1
==
nLimit
)
{
for
(
i
=
0
;
i
<
nSizeC0
;
i
++
)
if
(
pC0
->
pLeaves
[
i
]
!=
pC1
->
pLeaves
[
i
]
)
return
0
;
}
else
{
for
(
i
=
0
;
i
<
nSizeC1
;
i
++
)
{
for
(
k
=
nSizeC0
-
1
;
k
>=
0
;
k
--
)
if
(
pC0
->
pLeaves
[
k
]
==
pC1
->
pLeaves
[
i
]
)
break
;
if
(
k
==
-
1
)
// did not find
return
0
;
}
}
for
(
i
=
0
;
i
<
nSizeC0
;
i
++
)
pC
->
pLeaves
[
i
]
=
pC0
->
pLeaves
[
i
];
pC
->
nLeaves
=
nLimit
;
return
1
;
}
// compare two cuts with different numbers
i
=
k
=
c
=
0
;
while
(
1
)
{
if
(
c
==
nLimit
)
return
0
;
if
(
pC0
->
pLeaves
[
i
]
<
pC1
->
pLeaves
[
k
]
)
{
pC
->
pLeaves
[
c
++
]
=
pC0
->
pLeaves
[
i
++
];
if
(
i
>=
nSizeC0
)
goto
FlushCut1
;
}
else
if
(
pC0
->
pLeaves
[
i
]
>
pC1
->
pLeaves
[
k
]
)
{
pC
->
pLeaves
[
c
++
]
=
pC1
->
pLeaves
[
k
++
];
if
(
k
>=
nSizeC1
)
goto
FlushCut0
;
}
else
{
pC
->
pLeaves
[
c
++
]
=
pC0
->
pLeaves
[
i
++
];
k
++
;
if
(
i
>=
nSizeC0
)
goto
FlushCut1
;
if
(
k
>=
nSizeC1
)
goto
FlushCut0
;
}
}
FlushCut0
:
if
(
c
+
nSizeC0
>
nLimit
+
i
)
return
0
;
while
(
i
<
nSizeC0
)
pC
->
pLeaves
[
c
++
]
=
pC0
->
pLeaves
[
i
++
];
pC
->
nLeaves
=
c
;
return
1
;
FlushCut1
:
if
(
c
+
nSizeC1
>
nLimit
+
k
)
return
0
;
while
(
k
<
nSizeC1
)
pC
->
pLeaves
[
c
++
]
=
pC1
->
pLeaves
[
k
++
];
pC
->
nLeaves
=
c
;
return
1
;
}
/**Function*************************************************************
Synopsis [Merges two cuts.]
Description [Special case when the cut is known to exist.]
SideEffects []
...
...
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