com.github.andyshao.lang.CharWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Gear Show documentation
Show all versions of Gear Show documentation
Enhance and formating the coding of JDK
The newest version!
package com.github.andyshao.lang;
import java.math.BigInteger;
import java.util.Iterator;
/**
*
* Title:
* Descript:
* Copyright: Copryright(c) Apr 5, 2015
* Encoding:UNIX UTF-8
*
* @author Andy.Shao
*
* @param array type
*/
public interface CharWrapper {
/**byte char wrapper*/
public static final CharWrapper BYTE_CHAR_WRAPPER = new ByteCharWrapper();
/**char to char wrapper*/
public static final CharWrapper CHAR_CHAR_WRAPPER = new CharCharWrapper();
/**int char wrapper*/
public static final CharWrapper INT_CHAR_WRAPPER = new IntCharWrapper();
/**long char wrapper*/
public static final CharWrapper LONG_CHAR_WRAPPER = new LongCharWrapper();
/**short char wrapper*/
public static final CharWrapper SHORT_CHAR_WRAPPER = new ShortCharWrapper();
/**
* get char
* @param array array
* @param position position
* @return the value
*/
public char getChar(ARRAY array , BigInteger position);
/**
* char {@link Iterator}
* @param array the array
* @return {@link Iterator}
*/
public default Iterator iterator(final ARRAY array) {
return new Iterator() {
private volatile BigInteger index = BigInteger.ZERO;
private final BigInteger size = CharWrapper.this.size(array);
@Override
public boolean hasNext() {
return (this.index.compareTo(this.size) == -1);
}
@Override
public Character next() {
char c = CharWrapper.this.getChar(array , this.index);
this.index = this.index.add(BigInteger.ONE);
return c;
}
};
}
/**
* set char
* @param array array
* @param position position
* @param c char value
*/
public void setChar(ARRAY array , BigInteger position , char c);
/**
* size
* @param array array
* @return size number
*/
public BigInteger size(ARRAY array);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy