Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
tsai
StackExchange.Redis
Commits
ee7576fa
Commit
ee7576fa
authored
Mar 11, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: SortedSetEntry
parent
343d1345
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
46 deletions
+28
-46
SortedSetEntry.cs
StackExchange.Redis/StackExchange/Redis/SortedSetEntry.cs
+28
-46
No files found.
StackExchange.Redis/StackExchange/Redis/SortedSetEntry.cs
View file @
ee7576fa
...
...
@@ -4,10 +4,6 @@
namespace
StackExchange.Redis
{
/// <summary>
/// Describes a sorted-set element with the corresponding value
/// </summary>
...
...
@@ -17,13 +13,16 @@ public struct SortedSetEntry : IEquatable<SortedSetEntry>, IComparable, ICompara
internal
readonly
double
score
;
/// <summary>
/// Initializes a
SortedSetEntry value
/// Initializes a
<see cref="SortedSetEntry"/> value.
/// </summary>
/// <param name="element">The <see cref="RedisValue"/> to get an entry for.</param>
/// <param name="score">The redis score for <paramref name="element"/>.</param>
public
SortedSetEntry
(
RedisValue
element
,
double
score
)
{
this
.
element
=
element
;
this
.
score
=
score
;
}
/// <summary>
/// The unique element stored in the sorted set
/// </summary>
...
...
@@ -51,78 +50,61 @@ public SortedSetEntry(RedisValue element, double score)
/// <summary>
/// Converts to a key/value pair
/// </summary>
public
static
implicit
operator
KeyValuePair
<
RedisValue
,
double
>(
SortedSetEntry
value
)
{
return
new
KeyValuePair
<
RedisValue
,
double
>(
value
.
element
,
value
.
score
);
}
/// <param name="value">The <see cref="SortedSetEntry"/> to get a <see cref="KeyValuePair{TKey, TValue}"/> for.</param>
public
static
implicit
operator
KeyValuePair
<
RedisValue
,
double
>(
SortedSetEntry
value
)
=>
new
KeyValuePair
<
RedisValue
,
double
>(
value
.
element
,
value
.
score
);
/// <summary>
/// Converts from a key/value pair
/// </summary>
public
static
implicit
operator
SortedSetEntry
(
KeyValuePair
<
RedisValue
,
double
>
value
)
{
return
new
SortedSetEntry
(
value
.
Key
,
value
.
Value
);
}
/// <param name="value">The <see cref="KeyValuePair{TKey, TValue}"/> to get a <see cref="SortedSetEntry"/> for.</param>
public
static
implicit
operator
SortedSetEntry
(
KeyValuePair
<
RedisValue
,
double
>
value
)
=>
new
SortedSetEntry
(
value
.
Key
,
value
.
Value
);
/// <summary>
/// See Object.ToString()
/// </summary>
public
override
string
ToString
()
{
return
element
+
": "
+
score
;
}
public
override
string
ToString
()
=>
element
+
": "
+
score
;
/// <summary>
/// See Object.GetHashCode()
/// </summary>
public
override
int
GetHashCode
()
{
return
element
.
GetHashCode
()
^
score
.
GetHashCode
();
}
public
override
int
GetHashCode
()
=>
element
.
GetHashCode
()
^
score
.
GetHashCode
();
/// <summary>
/// Compares two values for equality
/// </summary>
public
override
bool
Equals
(
object
obj
)
{
return
obj
is
SortedSetEntry
&&
Equals
((
SortedSetEntry
)
obj
);
}
/// <param name="obj">The <see cref="SortedSetEntry"/> to compare to.</param>
public
override
bool
Equals
(
object
obj
)
=>
obj
is
SortedSetEntry
ssObj
&&
Equals
(
ssObj
);
/// <summary>
/// Compares two values for equality
/// </summary>
public
bool
Equals
(
SortedSetEntry
other
)
{
return
score
==
other
.
score
&&
element
==
other
.
element
;
}
/// <param name="other">The <see cref="SortedSetEntry"/> to compare to.</param>
public
bool
Equals
(
SortedSetEntry
other
)
=>
score
==
other
.
score
&&
element
==
other
.
element
;
/// <summary>
/// Compares two values by score
/// </summary>
public
int
CompareTo
(
SortedSetEntry
other
)
{
return
score
.
CompareTo
(
other
.
score
);
}
/// <param name="other">The <see cref="SortedSetEntry"/> to compare to.</param>
public
int
CompareTo
(
SortedSetEntry
other
)
=>
score
.
CompareTo
(
other
.
score
);
/// <summary>
/// Compares two values by score
/// </summary>
public
int
CompareTo
(
object
obj
)
{
return
obj
is
SortedSetEntry
?
CompareTo
((
SortedSetEntry
)
obj
)
:
-
1
;
}
/// <param name="obj">The <see cref="SortedSetEntry"/> to compare to.</param>
public
int
CompareTo
(
object
obj
)
=>
obj
is
SortedSetEntry
ssObj
?
CompareTo
(
ssObj
)
:
-
1
;
/// <summary>
/// Compares two values for equality
/// </summary>
public
static
bool
operator
==(
SortedSetEntry
x
,
SortedSetEntry
y
)
{
return
x
.
score
==
y
.
score
&&
x
.
element
==
y
.
element
;
}
/// <param name="x">The first <see cref="SortedSetEntry"/> to compare.</param>
/// <param name="y">The second <see cref="SortedSetEntry"/> to compare.</param>
public
static
bool
operator
==(
SortedSetEntry
x
,
SortedSetEntry
y
)
=>
x
.
score
==
y
.
score
&&
x
.
element
==
y
.
element
;
/// <summary>
/// Compares two values for non-equality
/// </summary>
public
static
bool
operator
!=(
SortedSetEntry
x
,
SortedSetEntry
y
)
{
return
x
.
score
!=
y
.
score
||
x
.
element
!=
y
.
element
;
}
/// <param name="x">The first <see cref="SortedSetEntry"/> to compare.</param>
/// <param name="y">The second <see cref="SortedSetEntry"/> to compare.</param>
public
static
bool
operator
!=(
SortedSetEntry
x
,
SortedSetEntry
y
)
=>
x
.
score
!=
y
.
score
||
x
.
element
!=
y
.
element
;
}
}
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