提交 c1b159d4 authored 作者: Thomas Mueller's avatar Thomas Mueller

Documentation

上级 69ea2e49
...@@ -103,6 +103,11 @@ public abstract class ImmutableArray3<K> implements Iterable<K> { ...@@ -103,6 +103,11 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
return array; return array;
} }
/**
* Get the level of "abstraction".
*
* @return the level
*/
abstract int level(); abstract int level();
@Override @Override
...@@ -166,7 +171,7 @@ public abstract class ImmutableArray3<K> implements Iterable<K> { ...@@ -166,7 +171,7 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
/** /**
* The array. * The array.
*/ */
final K[] array; private final K[] array;
public Plain(K[] array) { public Plain(K[] array) {
this.array = array; this.array = array;
...@@ -197,6 +202,15 @@ public abstract class ImmutableArray3<K> implements Iterable<K> { ...@@ -197,6 +202,15 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
return new Remove<K>(this, index); return new Remove<K>(this, index);
} }
/**
* Get a plain array with the given entry updated.
*
* @param <K> the type
* @param base the base type
* @param index the index
* @param obj the object
* @return the immutable array
*/
static <K> ImmutableArray3<K> set(ImmutableArray3<K> base, int index, K obj) { static <K> ImmutableArray3<K> set(ImmutableArray3<K> base, int index, K obj) {
int len = base.length(); int len = base.length();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -207,6 +221,15 @@ public abstract class ImmutableArray3<K> implements Iterable<K> { ...@@ -207,6 +221,15 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
return new Plain<K>(array); return new Plain<K>(array);
} }
/**
* Get a plain array with the given entry inserted.
*
* @param <K> the type
* @param base the base type
* @param index the index
* @param obj the object
* @return the immutable array
*/
static <K> ImmutableArray3<K> insert(ImmutableArray3<K> base, int index, K obj) { static <K> ImmutableArray3<K> insert(ImmutableArray3<K> base, int index, K obj) {
int len = base.length() + 1; int len = base.length() + 1;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -217,6 +240,14 @@ public abstract class ImmutableArray3<K> implements Iterable<K> { ...@@ -217,6 +240,14 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
return new Plain<K>(array); return new Plain<K>(array);
} }
/**
* Get a plain array with the given entry removed.
*
* @param <K> the type
* @param base the base type
* @param index the index
* @return the immutable array
*/
static <K> ImmutableArray3<K> remove(ImmutableArray3<K> base, int index) { static <K> ImmutableArray3<K> remove(ImmutableArray3<K> base, int index) {
int len = base.length() - 1; int len = base.length() - 1;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -242,9 +273,9 @@ public abstract class ImmutableArray3<K> implements Iterable<K> { ...@@ -242,9 +273,9 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
*/ */
static class Set<K> extends ImmutableArray3<K> { static class Set<K> extends ImmutableArray3<K> {
final int index; private final int index;
final ImmutableArray3<K> base; private final ImmutableArray3<K> base;
final K obj; private final K obj;
Set(ImmutableArray3<K> base, int index, K obj) { Set(ImmutableArray3<K> base, int index, K obj) {
this.base = base; this.base = base;
...@@ -303,9 +334,9 @@ public abstract class ImmutableArray3<K> implements Iterable<K> { ...@@ -303,9 +334,9 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
*/ */
static class Insert<K> extends ImmutableArray3<K> { static class Insert<K> extends ImmutableArray3<K> {
final int index; private final int index;
final ImmutableArray3<K> base; private final ImmutableArray3<K> base;
final K obj; private final K obj;
Insert(ImmutableArray3<K> base, int index, K obj) { Insert(ImmutableArray3<K> base, int index, K obj) {
this.base = base; this.base = base;
...@@ -369,8 +400,8 @@ public abstract class ImmutableArray3<K> implements Iterable<K> { ...@@ -369,8 +400,8 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
*/ */
static class Remove<K> extends ImmutableArray3<K> { static class Remove<K> extends ImmutableArray3<K> {
final int index; private final int index;
final ImmutableArray3<K> base; private final ImmutableArray3<K> base;
Remove(ImmutableArray3<K> base, int index) { Remove(ImmutableArray3<K> base, int index) {
this.base = base; this.base = base;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论