Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
3edb1960
Commit
3edb1960
authored
9 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
subtree jump table for PrefixRankedTree
parent
be25da0d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
alib2algo/src/arbology/exact/SubtreeJumpTable.cpp
+34
-2
34 additions, 2 deletions
alib2algo/src/arbology/exact/SubtreeJumpTable.cpp
alib2algo/src/arbology/exact/SubtreeJumpTable.h
+3
-0
3 additions, 0 deletions
alib2algo/src/arbology/exact/SubtreeJumpTable.h
with
37 additions
and
2 deletions
alib2algo/src/arbology/exact/SubtreeJumpTable.cpp
+
34
−
2
View file @
3edb1960
...
...
@@ -8,8 +8,8 @@
#include
"SubtreeJumpTable.h"
#include
<exception/AlibException.h>
#include
<tree/ranked/PrefixRankedTree.h>
#include
<tree/ranked/PrefixRankedBarTree.h>
#include
<tree/ranked/PrefixRankedBarPattern.h>
#include
<alphabet/RankedSymbol.h>
#include
<map>
...
...
@@ -30,6 +30,18 @@ std::vector < int > SubtreeJumpTable::compute ( const tree::PrefixRankedBarTree
return
res
;
}
auto
SubtreeSizesPrefixRankedBarTree
=
SubtreeJumpTable
::
RegistratorWrapper
<
std
::
vector
<
int
>
,
tree
::
PrefixRankedBarTree
>
(
SubtreeJumpTable
::
getInstance
(
),
SubtreeJumpTable
::
compute
);
std
::
vector
<
int
>
SubtreeJumpTable
::
compute
(
const
tree
::
PrefixRankedTree
&
subject
)
{
std
::
vector
<
int
>
res
;
buildDataPointers
(
res
,
subject
,
0
);
return
res
;
}
auto
SubtreeSizesPrefixRankedTree
=
SubtreeJumpTable
::
RegistratorWrapper
<
std
::
vector
<
int
>
,
tree
::
PrefixRankedTree
>
(
SubtreeJumpTable
::
getInstance
(
),
SubtreeJumpTable
::
compute
);
/**
*
used
to
compute
subtree
jump
table
.
*
@
param
begin
-
index
of
a
root
node
of
a
complete
subtree
to
process
...
...
@@ -49,7 +61,27 @@ int SubtreeJumpTable::buildDataPointers ( std::vector < int > & res, const tree:
return
index
;
}
auto
SubtreeSizesPrefixRankedBarTree
=
SubtreeJumpTable
::
RegistratorWrapper
<
std
::
vector
<
int
>
,
tree
::
PrefixRankedBarTree
>
(
SubtreeJumpTable
::
getInstance
(
),
SubtreeJumpTable
::
compute
);
/**
*
used
to
compute
subtree
jump
table
.
*
@
param
begin
-
index
of
a
root
node
of
a
complete
subtree
to
process
*
@
return
index
,
increased
by
one
,
of
the
last
node
in
the
subtree
starting
at
index
begin
*/
int
SubtreeJumpTable
::
buildDataPointers
(
std
::
vector
<
int
>
&
res
,
const
tree
::
PrefixRankedTree
&
subject
,
int
begin
)
{
for
(
unsigned
i
=
0
;
i
<
subject
.
getContent
(
).
size
(
);
i
++
)
res
.
push_back
(
0
);
return
buildDataPointersInternal
(
res
,
subject
,
begin
);
}
int
SubtreeJumpTable
::
buildDataPointersInternal
(
std
::
vector
<
int
>
&
res
,
const
tree
::
PrefixRankedTree
&
subject
,
int
begin
)
{
int
index
=
begin
+
1
;
for
(
unsigned
i
=
0
;
i
<
subject
.
getContent
(
)[
begin
].
getRank
(
).
getData
(
);
i
++
)
index
=
buildDataPointersInternal
(
res
,
subject
,
index
);
res
[
begin
]
=
index
;
return
index
;
}
}
/* namespace exact */
...
...
This diff is collapsed.
Click to expand it.
alib2algo/src/arbology/exact/SubtreeJumpTable.h
+
3
−
0
View file @
3edb1960
...
...
@@ -24,8 +24,11 @@ public:
static std::vector < int > compute ( const tree::RankedTreeWrapper & subject );
static std::vector < int > compute ( const tree::PrefixRankedBarTree & subject );
static std::vector < int > compute ( const tree::PrefixRankedTree & subject );
static int buildDataPointers ( std::vector < int > & res, const tree::PrefixRankedBarTree & subject, int begin );
static int buildDataPointers ( std::vector < int > & res, const tree::PrefixRankedTree & subject, int begin );
static int buildDataPointersInternal ( std::vector < int > & res, const tree::PrefixRankedTree & subject, int begin );
static SubtreeJumpTable & getInstance ( ) {
static SubtreeJumpTable res;
...
...
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