Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Spot
Spot
Commits
7271242d
Commit
7271242d
authored
Mar 14, 2017
by
Etienne Renault
Browse files
bricks: update
* bricks/brick-hashset: here.
parent
24841303
Changes
1
Hide whitespace changes
Inline
Side-by-side
bricks/brick-hashset
View file @
7271242d
...
...
@@ -43,7 +43,8 @@ using hash::hash128_t;
struct
DefaultHasher
{
auto
hash
(
int64_t
v
)
const
->
std
::
pair
<
int64_t
,
int64_t
>
// auto hash( int64_t v ) const -> std::pair<int64_t, int64_t>
auto
hash
(
int64_t
v
)
const
{
return
std
::
make_pair
(
v
,
~
v
);
}
...
...
@@ -85,7 +86,7 @@ struct FastCell : CellBase< T, Hasher >
hash64_t
_hash
;
template
<
typename
Value
>
bool
is
(
Value
v
,
hash64_t
hash
,
Hasher
&
h
)
{
bool
is
(
const
Value
&
v
,
hash64_t
hash
,
Hasher
&
h
)
{
return
_hash
==
hash
&&
h
.
equal
(
_value
,
v
);
}
...
...
@@ -106,7 +107,7 @@ struct CompactCell : CellBase< T, Hasher >
T
_value
;
template
<
typename
Value
>
bool
is
(
Value
v
,
hash64_t
,
Hasher
&
h
)
{
bool
is
(
const
Value
&
v
,
hash64_t
,
Hasher
&
h
)
{
return
h
.
equal
(
_value
,
v
);
}
...
...
@@ -165,7 +166,7 @@ struct FastAtomicCell : CellBase< T, Hasher >
}
template
<
typename
Value
>
bool
is
(
Value
v
,
hash64_t
hash
,
Hasher
&
h
)
{
bool
is
(
const
Value
&
v
,
hash64_t
hash
,
Hasher
&
h
)
{
hash
|=
0x1
;
if
(
(
(
hash
<<
2
)
|
1
)
!=
(
_hashlock
|
1
)
)
return
false
;
...
...
@@ -248,7 +249,7 @@ struct AtomicCell : CellBase< T, Hasher >
}
template
<
typename
Value
>
bool
is
(
Value
v
,
hash64_t
hash
,
Hasher
&
h
)
{
bool
is
(
const
Value
&
v
,
hash64_t
hash
,
Hasher
&
h
)
{
return
value
.
load
().
tag
()
==
(
highbits
(
hash
,
Tagged
<
T
>::
tag_bits
)
|
1
)
&&
h
.
equal
(
value
.
load
().
t
,
v
);
}
...
...
@@ -606,7 +607,7 @@ struct _ConcurrentHashSet : HashSetBase< Cell >
}
template
<
typename
T
>
iterator
find
(
T
x
)
{
iterator
find
(
const
T
&
x
)
{
return
findHinted
(
x
,
hasher
.
hash
(
x
).
first
);
}
...
...
@@ -641,7 +642,7 @@ struct _ConcurrentHashSet : HashSetBase< Cell >
}
template
<
typename
T
>
iterator
findHinted
(
T
x
,
hash64_t
h
)
{
iterator
findHinted
(
const
T
&
x
,
hash64_t
h
)
{
while
(
true
)
{
Find
fr
=
findCell
(
x
,
h
,
_l
.
currentRow
);
switch
(
fr
.
r
)
{
...
...
@@ -661,7 +662,7 @@ struct _ConcurrentHashSet : HashSetBase< Cell >
}
template
<
typename
T
>
Find
findCell
(
T
v
,
hash64_t
h
,
unsigned
rowIndex
)
Find
findCell
(
const
T
&
v
,
hash64_t
h
,
unsigned
rowIndex
)
{
if
(
changed
(
rowIndex
)
)
return
Find
(
Resolution
::
Growing
);
...
...
@@ -848,13 +849,20 @@ struct _ConcurrentHashSet : HashSetBase< Cell >
}
while
(
true
);
}
void
increaseUsage
()
{
if
(
++
_l
.
inserts
==
syncPoint
)
{
_s
->
used
.
fetch_add
(
syncPoint
,
std
::
memory_order_relaxed
);
_l
.
inserts
=
0
;
}
void
increaseUsage
()
{
if
(
++
_l
.
inserts
==
syncPoint
)
updateUsage
();
}
void
updateUsage
()
{
_s
->
used
.
fetch_add
(
_l
.
inserts
,
std
::
memory_order_relaxed
);
_l
.
inserts
=
0
;
}
~
_ConcurrentHashSet
()
{
updateUsage
();
}
explicit
_ConcurrentHashSet
(
Hasher
h
=
Hasher
(),
unsigned
maxGrows
=
64
)
:
Base
(
h
),
_s
(
new
Shared
(
maxGrows
)
)
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment