T
- 生成范围对象的类型public class Range<T> extends Object implements Iterable<T>, Iterator<T>, Serializable
Range.Steper
来定义步进,因此Range本身无法判定边界(是否达到end),需在step实现边界判定逻辑。
此类使用ReentrantReadWriteLock
保证线程安全
Modifier and Type | Class and Description |
---|---|
static interface |
Range.Steper<T>
步进接口,此接口用于实现如何对一个对象按照指定步进增加步进
步进接口可以定义以下逻辑: |
Constructor and Description |
---|
Range(T start,
Range.Steper<T> steper)
构造
|
Range(T start,
T end,
Range.Steper<T> steper)
构造
|
Range(T start,
T end,
Range.Steper<T> steper,
boolean isIncludeStart,
boolean isIncludeEnd)
构造
|
Modifier and Type | Method and Description |
---|---|
Range<T> |
disableLock()
禁用锁,调用此方法后不在 使用锁保护
|
boolean |
hasNext() |
Iterator<T> |
iterator() |
T |
next() |
void |
remove() |
Range<T> |
reset()
重置
Range |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
forEachRemaining
public Range(T start, Range.Steper<T> steper)
start
- 起始对象steper
- 步进public Range(T start, T end, Range.Steper<T> steper)
start
- 起始对象(包含)end
- 结束对象(包含)steper
- 步进public Range(T start, T end, Range.Steper<T> steper, boolean isIncludeStart, boolean isIncludeEnd)
start
- 起始对象end
- 结束对象steper
- 步进isIncludeStart
- 是否包含第一个元素isIncludeEnd
- 是否包含最后一个元素Copyright © 2021. All rights reserved.