类 BitList<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- org.apache.dubbo.rpc.cluster.router.state.BitList<E>
-
- 类型参数:
E-
- 所有已实现的接口:
Iterable<E>,Collection<E>,List<E>
public class BitList<E> extends AbstractList<E>
BitList based on BitMap implementation. BitList is consists of `originList`, `rootSet` and `tailList`.originList: Initial elements of the list. This list will not be changed in modification actions (expect clear all). rootSet: A bitMap to store the indexes of originList are still exist. Most of the modification actions are operated on this bitMap. tailList: An additional list for BitList. Worked when adding totally new elements to list. These elements will be appended to the last of the BitList.
An example of BitList: originList: A B C D E (5 elements) rootSet: x v x v v 0 1 0 1 1 (5 elements) tailList: F G H (3 elements) resultList: B D E F G H (6 elements)
- 从以下版本开始:
- 3.0
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classBitList.BitListIterator<E>
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 booleanadd(E e)If the element to added is appeared in originList even if it is not in rootSet, directly set its index in rootSet to true.booleanaddAll(Collection<? extends E> c)voidaddIndex(int index)voidaddToTailList(E e)BitList<E>and(BitList<E> target)And operation between two bitList.voidclear()Caution: This operation will clear originList for removing references purpose.BitList<E>clone()ArrayList<E>cloneToArrayList()booleancontains(Object o)static <T> BitList<T>emptyList()Eget(int index)EgetByIndex(int index)List<E>getOriginList()List<E>getTailList()booleanhasMoreElementInTailList()booleanindexExist(int index)intindexOf(Object o)booleanisEmpty()Iterator<E>iterator()intlastIndexOf(Object o)ListIterator<E>listIterator()ListIterator<E>listIterator(int index)BitList<E>or(BitList<E> target)ErandomSelectOne()Eremove(int index)booleanremove(Object o)If the element to added is appeared in originList, directly set its index in rootSet to false.intsize()BitList<E>subList(int fromIndex, int toIndex)inttotalSetSize()-
从类继承的方法 java.util.AbstractCollection
containsAll, removeAll, retainAll, toArray, toArray, toString
-
从接口继承的方法 java.util.Collection
parallelStream, removeIf, stream, toArray
-
从接口继承的方法 java.util.List
containsAll, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
方法详细资料
-
addIndex
public void addIndex(int index)
-
totalSetSize
public int totalSetSize()
-
indexExist
public boolean indexExist(int index)
-
getByIndex
public E getByIndex(int index)
-
and
public BitList<E> and(BitList<E> target)
And operation between two bitList. Return a new cloned list. TailList in source bitList will be totally saved even if it is not appeared in the target bitList.- 参数:
target- target bitList- 返回:
- a new bitList only contains those elements contain in both two list and source bitList's tailList
-
hasMoreElementInTailList
public boolean hasMoreElementInTailList()
-
addToTailList
public void addToTailList(E e)
-
randomSelectOne
public E randomSelectOne()
-
emptyList
public static <T> BitList<T> emptyList()
-
size
public int size()
- 指定者:
size在接口中Collection<E>- 指定者:
size在接口中List<E>- 指定者:
size在类中AbstractCollection<E>
-
contains
public boolean contains(Object o)
- 指定者:
contains在接口中Collection<E>- 指定者:
contains在接口中List<E>- 覆盖:
contains在类中AbstractCollection<E>
-
add
public boolean add(E e)
If the element to added is appeared in originList even if it is not in rootSet, directly set its index in rootSet to true. (This may change the order of elements.)If the element is not contained in originList, allocate tailList and add to tailList.
Notice: It is not recommended adding duplicated element.
- 指定者:
add在接口中Collection<E>- 指定者:
add在接口中List<E>- 覆盖:
add在类中AbstractList<E>
-
remove
public boolean remove(Object o)
If the element to added is appeared in originList, directly set its index in rootSet to false. (This may change the order of elements.)If the element is not contained in originList, try to remove from tailList.
- 指定者:
remove在接口中Collection<E>- 指定者:
remove在接口中List<E>- 覆盖:
remove在类中AbstractCollection<E>
-
clear
public void clear()
Caution: This operation will clear originList for removing references purpose. This may change the default behaviour when adding new element later.- 指定者:
clear在接口中Collection<E>- 指定者:
clear在接口中List<E>- 覆盖:
clear在类中AbstractList<E>
-
addAll
public boolean addAll(Collection<? extends E> c)
- 指定者:
addAll在接口中Collection<E>- 指定者:
addAll在接口中List<E>- 覆盖:
addAll在类中AbstractCollection<E>
-
lastIndexOf
public int lastIndexOf(Object o)
- 指定者:
lastIndexOf在接口中List<E>- 覆盖:
lastIndexOf在类中AbstractList<E>
-
isEmpty
public boolean isEmpty()
- 指定者:
isEmpty在接口中Collection<E>- 指定者:
isEmpty在接口中List<E>- 覆盖:
isEmpty在类中AbstractCollection<E>
-
listIterator
public ListIterator<E> listIterator()
- 指定者:
listIterator在接口中List<E>- 覆盖:
listIterator在类中AbstractList<E>
-
listIterator
public ListIterator<E> listIterator(int index)
- 指定者:
listIterator在接口中List<E>- 覆盖:
listIterator在类中AbstractList<E>
-
-