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
175b42b4
Commit
175b42b4
authored
Apr 10, 2017
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiments with hashing.
parent
fe3d3341
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
src/misc/util/utilNam.c
+22
-2
src/misc/util/utilNam.h
+1
-1
No files found.
src/misc/util/utilNam.c
View file @
175b42b4
...
@@ -131,11 +131,15 @@ void Abc_NamStop( Abc_Nam_t * p )
...
@@ -131,11 +131,15 @@ void Abc_NamStop( Abc_Nam_t * p )
SeeAlso []
SeeAlso []
***********************************************************************/
***********************************************************************/
void
Abc_NamPrint
(
Abc_Nam_t
*
p
)
void
Abc_NamPrint
(
Abc_Nam_t
*
p
,
char
*
pFileName
)
{
{
FILE
*
pFile
=
pFileName
?
fopen
(
pFileName
,
"wb"
)
:
stdout
;
int
h
,
i
;
int
h
,
i
;
if
(
pFile
==
NULL
)
{
printf
(
"Count node open file %s
\n
"
,
pFileName
);
return
;
}
Vec_IntForEachEntryStart
(
&
p
->
vInt2Handle
,
h
,
i
,
1
)
Vec_IntForEachEntryStart
(
&
p
->
vInt2Handle
,
h
,
i
,
1
)
Abc_Print
(
1
,
"%d=
\n
%s
\n
"
,
i
,
Abc_NamHandleToStr
(
p
,
h
)
);
fprintf
(
pFile
,
"%8d = %s
\n
"
,
i
,
Abc_NamHandleToStr
(
p
,
h
)
);
if
(
pFile
!=
stdout
)
fclose
(
pFile
);
}
}
/**Function*************************************************************
/**Function*************************************************************
...
@@ -275,6 +279,22 @@ int Abc_NamStrHash( const char * pStr, const char * pLim, int nTableSize )
...
@@ -275,6 +279,22 @@ int Abc_NamStrHash( const char * pStr, const char * pLim, int nTableSize )
}
}
return
uHash
%
nTableSize
;
return
uHash
%
nTableSize
;
}
}
// https://en.wikipedia.org/wiki/Jenkins_hash_function
int
Abc_NamStrHash2
(
const
char
*
pStr
,
const
char
*
pLim
,
int
nTableSize
)
{
int
nSize
=
pLim
?
pLim
-
pStr
:
-
1
;
int
i
=
0
;
unsigned
hash
=
0
;
while
(
i
!=
nSize
&&
pStr
[
i
]
)
{
hash
+=
pStr
[
i
++
];
hash
+=
hash
<<
10
;
hash
^=
hash
>>
6
;
}
hash
+=
hash
<<
3
;
hash
^=
hash
>>
11
;
hash
+=
hash
<<
15
;
return
(
int
)(
hash
%
nTableSize
);
}
/**Function*************************************************************
/**Function*************************************************************
...
...
src/misc/util/utilNam.h
View file @
175b42b4
...
@@ -52,7 +52,7 @@ typedef struct Abc_Nam_t_ Abc_Nam_t;
...
@@ -52,7 +52,7 @@ typedef struct Abc_Nam_t_ Abc_Nam_t;
/*=== utilNam.c ===============================================================*/
/*=== utilNam.c ===============================================================*/
extern
Abc_Nam_t
*
Abc_NamStart
(
int
nObjs
,
int
nAveSize
);
extern
Abc_Nam_t
*
Abc_NamStart
(
int
nObjs
,
int
nAveSize
);
extern
void
Abc_NamStop
(
Abc_Nam_t
*
p
);
extern
void
Abc_NamStop
(
Abc_Nam_t
*
p
);
extern
void
Abc_NamPrint
(
Abc_Nam_t
*
p
);
extern
void
Abc_NamPrint
(
Abc_Nam_t
*
p
,
char
*
pFileName
);
extern
Abc_Nam_t
*
Abc_NamRef
(
Abc_Nam_t
*
p
);
extern
Abc_Nam_t
*
Abc_NamRef
(
Abc_Nam_t
*
p
);
extern
void
Abc_NamDeref
(
Abc_Nam_t
*
p
);
extern
void
Abc_NamDeref
(
Abc_Nam_t
*
p
);
extern
int
Abc_NamObjNumMax
(
Abc_Nam_t
*
p
);
extern
int
Abc_NamObjNumMax
(
Abc_Nam_t
*
p
);
...
...
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