コード例 #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is DefaultElectionCredentials))
            {
                return(false);
            }
            DefaultElectionCredentials other = ( DefaultElectionCredentials )obj;

            return(other._serverId == this._serverId && other._latestTxId == this._latestTxId && other._currentWinner == this._currentWinner);
        }
コード例 #2
0
        public override int CompareTo(ElectionCredentials o)
        {
            DefaultElectionCredentials other = ( DefaultElectionCredentials )o;

            if (this._latestTxId == other._latestTxId)
            {
                // Smaller id means higher priority
                if (this._currentWinner == other._currentWinner)
                {
                    return(Integer.compare(other._serverId, this._serverId));
                }
                else
                {
                    return(other._currentWinner ? -1 : 1);
                }
            }
            else
            {
                return(Long.compare(this._latestTxId, other._latestTxId));
            }
        }