本文整理汇总了C#中System.Object.equals方法的典型用法代码示例。如果您正苦于以下问题:C# Object.equals方法的具体用法?C# Object.equals怎么用?C# Object.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Object
的用法示例。
在下文中一共展示了Object.equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compare
//public double GetDefault() {
// return 1.0;
//}
/// This is used to compare the expected and current versions of
/// the class. Once compared the comparison result is cached
/// within the revision class so that it can be used repeatedly.
/// </summary>
/// <param name="expected">
/// this is the expected version of the class
/// </param>
/// <param name="current">
/// this is the current version of the class
/// </param>
/// <returns>
/// this returns true if the versions are the same
/// </returns>
public bool Compare(Object expected, Object current) {
if(current != null) {
equal = current.equals(expected);
} else if(expected != null) {
equal = expected.equals(1.0);
}
return equal;
}
示例2: isEqualKey
/**
* Is the key equal to the combined key.
*
* @param entry the entry to compare to
* @param key1 the first key
* @param key2 the second key
* @param key3 the third key
* @param key4 the fourth key
* @return true if the key matches
*/
protected bool isEqualKey(AbstractHashedMap.HashEntry entry, Object key1, Object key2, Object key3, Object key4)
{
MultiKey multi = (MultiKey)entry.getKey();
return
multi.size() == 4 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
(key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) &&
(key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3)));
}
示例3: removeAll
/**
* Removes all mappings where the first four keys are those specified.
* <p>
* This method removes all the mappings where the <code>MultiKey</code>
* has four or more keys, and the first four match those specified.
*
* @param key1 the first key
* @param key2 the second key
* @param key3 the third key
* @param key4 the fourth key
* @return true if any elements were removed
*/
public bool removeAll(Object key1, Object key2, Object key3, Object key4)
{
bool modified = false;
MapIterator it = mapIterator();
while (it.hasNext())
{
MultiKey multi = (MultiKey)it.next();
if (multi.size() >= 4 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
(key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) &&
(key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3))))
{
it.remove();
modified = true;
}
}
return modified;
}
示例4: cardinality
/**
* Returns the number of occurrences of <i>obj</i> in <i>coll</i>.
*
* @param obj the object to find the cardinality of
* @param coll the collection to search
* @return the the number of occurrences of obj in coll
*/
public static int cardinality(Object obj, java.util.Collection<Object> coll)
{
if (coll is java.util.Set<Object>)
{
return (coll.contains(obj) ? 1 : 0);
}
if (coll is Bag)
{
return ((Bag)coll).getCount(obj);
}
int count = 0;
if (obj == null)
{
for (java.util.Iterator<Object> it = coll.iterator(); it.hasNext(); )
{
if (it.next() == null)
{
count++;
}
}
}
else
{
for (java.util.Iterator<Object> it = coll.iterator(); it.hasNext(); )
{
if (obj.equals(it.next()))
{
count++;
}
}
}
return count;
}