分享
 
 
 

java.util.AbstractSet翻译

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

[/url] [url=file:///F:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/overview-summary.html]Overview

Package

Class

Use

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Std. Ed. v1.4.2

PREV CLASS NEXT CLASS

FRAMES NO FRAMES All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

java.util

Class AbstractSetjava.lang.Object

java.util.AbstractCollection

java.util.AbstractSet

All Implemented Interfaces: Collection, Set Direct Known Subclasses: HashSet, TreeSet public abstract class AbstractSet extends AbstractCollection implements SetThis class provides a skeletal implementation of the Set interface to minimize the effort required to implement this interface. 该类提供了接口Set的框架实现,用来降低实现该接口的复杂程度。

The process of implementing a set by extending this class is identical to that of implementing a Collection by extending AbstractCollection, except that all of the methods and constructors in subclasses of this class must obey the additional constraints imposed by the Set interface (for instance, the add method must not permit addition of multiple intances of an object to a set). 通过继承该类以实现set的过程和通过继承AbstractCollection实现Collection一样, 除了该类子类的所有方法和构造函数必须遵守Set接口的一些额外约定(例如,add方法不允许向set中加入重复对象)。

Note that this class does not override any of the implementations from the AbstractCollection class. It merely adds implementations for equals and hashCode. 注意该类没有重载AbstractCollection类的任何实现。它只是增加了equals和hashCode的实现。

This class is a member of the Java Collections Framework. 该类是Java集合框架成员之一。

Since: 1.2 See Also: Collection, AbstractCollection, SetConstructor Summary

protected

AbstractSet()

Sole constructor. 唯一的构造函数。

Method Summary

boolean

equals(Object o)

Compares the specified object with this set for equality. 将指定对象和当前set就相等性进行比较。

int

hashCode()

Returns the hash code value for this set. 返回set的哈希码值。

boolean

removeAll(Collection c)

Removes from this set all of its elements that are contained in the specified collection (optional operation). 从set中删除指定集合所包含的所有元素(可选操作)。

Methods inherited from class java.util.AbstractCollection

add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, retainAll, size, toArray, )]toArray, toString

Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.Set

add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, retainAll, size, toArray, )]toArray

Constructor Detail

AbstractSetprotected AbstractSet()

Sole constructor. (For invocation by subclass constructors, typically implicit.) 唯一的构造函数。(通常由子类隐式调用)

Method Detail

equalspublic boolean equals(Object o)

Compares the specified object with this set for equality. Returns true if the given object is also a set, the two sets have the same size, and every member of the given set is contained in this set. This ensures that the equals method works properly across different implementations of the Set interface. 将指定对象和当前set就相等性进行比较。如果指定对象也是一个set,两个set有着相同大小,指定set的每一个成员在当前 set中。该定义可以保证对于set接口的不同实现,equals方法都能正常工作。 This implementation first checks if the specified object is this set; if so it returns true. Then, it checks if the specified object is a set whose size is identical to the size of this set; if not, it it returns false. If so, it returns containsAll((Collection) o). 实现首先检查指定对象是否是当前set,如果是返回true。然后,检查指定对象是否是一个set,大小是否和当前set的一样, 如果不是,返回false。如果是,返回containsAll((Collection) o)。

Specified by: equals in interface Set Overrides: equals in class ObjectParameters: o - Object to be compared for equality with this set. 同当前set比较相等性的Object。 Returns: true if the specified object is equal to this set. 如果指定对象和当前set相等,返回true。 See Also: Object.hashCode(), HashtablehashCodepublic int hashCode()

Returns the hash code value for this set. The hash code of a set is defined to be the sum of the hash codes of the elements in the set. This ensures that s1.equals(s2) implies that s1.hashCode()==s2.hashCode() for any two sets s1 and s2, as required by the general contract of Object.hashCode. 返回set的哈希码值。set的哈希码被定义为set中元素的哈希码之和, 这里null元素的哈希码被定义为0。 这将保证对于两个set s1和s2, s1.equals(s2)意味着s1.hashCode()==s2.hashCode(),遵循 Object.hashCode方法的一般约定。 This implementation enumerates over the set, calling the hashCode method on each element in the collection, and adding up the results. 实现对set进行枚举,对集合中每一个元素调用hashCode方法,然后将结果相加。

Specified by: hashCode in interface Set Overrides: hashCode in class ObjectReturns: the hash code value for this set. set的哈希码值。 See Also: Object.equals(java.lang.Object), HashtableremoveAllpublic boolean removeAll(Collection c)

Removes from this set all of its elements that are contained in the specified collection (optional operation). 从set中删除指定集合所包含的所有元素(可选操作)。 This implementation determines which is the smaller of this set and the specified collection, by invoking the size method on each. If this set has fewer elements, then the implementation iterates over this set, checking each element returned by the iterator in turn to see if it is contained in the specified collection. If it is so contained, it is removed from this set with the iterator's remove method. If the specified collection has fewer elements, then the implementation iterates over the specified collection, removing from this set each element returned by the iterator, using this set's remove method. 该实现首先通过调用size方法来确定当前set和指定集合哪个更小。如果set的元素更少, 那么实现遍历set,按顺序检查由迭代器返回的每一个元素,查看指定集合中是否包含。 如果包含,使用迭代器的remove方法从set中删除。如果指定集合的元素更少,那么遍历指定集合, 使用set的remove方法来从set中删除由迭代器返回的每一个元素。

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method. 注意如果由iterator方法返回的迭代器没有实现remove方法,实现将抛出UnsupportedOperationException。

Specified by: removeAll in interface Set Overrides: removeAll in class AbstractCollectionParameters: c - elements to be removed from this set. 要从set中删除的元素。 Returns: true if this set changed as a result of the call. 如果调用的结果改变了set,返回true。 Throws: UnsupportedOperationException - removeAll is not supported by this set. set不支持removeAll则抛出。 NullPointerException - if the specified collection is null. 如果指定集合为null时抛出。 See Also: AbstractCollection.remove(Object), AbstractCollection.contains(Object)[/url][url=file:///F:/资料/文字资料/j2sdk-1_4_2-doc/docs/api/overview-summary.html]Overview

Package

Class

Use

Tree

Deprecated

Index

Help

JavaTM 2 Platform

Std. Ed. v1.4.2

PREV CLASS NEXT CLASS

FRAMES NO FRAMES All Classes

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature

For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有