Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2015 Santhosh Kumar Tekuri The JLibs authors license this file to you under the Apache License, version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package jlibs.nbp;
 
 
 import static java.lang.Character.*;

Author(s):
Santhosh Kumar T
 
 public final class Chars implements CharSequence{
     private char buff[] = new char[100];
     public int count;
 
     private int stack[] = new int[50];
     int free = 0;
 
     public boolean isBuffering(){
         return >0;
     }
 
     public void push(){
         if(>=.)
              = Arrays.copyOf(.<<1);
         [++] = ;
     }
 
     public void expandCapacity(int increment){
         int newCapacity = (.+increment)<<1;
         if(newCapacity<0)
             newCapacity = .;
          = Arrays.copyOf(newCapacity);
     }
 
     public void append(char character){
         if(==.)
             expandCapacity(1);
         [++] = character;
     }
 
     public void append(char chars[], int offsetint len){
         if(+len==chars.length)
             expandCapacity(len);
         System.arraycopy(charsoffsetlen);
          += len;
     }
 
     public void append(int codePoint){
         if(codePoint<){
             if(==.)
                 expandCapacity(1);
             [++] = (char)codePoint;
         }else{
             if(==.-1)
                 expandCapacity(2);
             int offset = codePoint - ;
             [++] = (char)((offset >>> 10) + );
             [++] = (char)((offset & 0x3ff) + );
         }
     }
 
     public Chars pop(int beginint end){
          = begin + [--];
          = -end;
         if(==0)
              = 0;
         return this;
     }
 
     public void clear(){
          =  = 0;
     }
     
     /*-------------------------------------------------[ CharSequence ]---------------------------------------------------*/
     
     private int offsetlength;
     public char[] array(){
         return ;
     }
 
     public int offset(){
         return ;
     }
    public int length(){
        return ;
    }
    @Override
    public char charAt(int index){
        if(index<0 || index>=)
            throw new IndexOutOfBoundsException(index+" is not in range [0, "++")");
        else
            return [+index];
    }
    @Override
    public CharSequence subSequence(int startint end){
        if(start<0)
            throw new IndexOutOfBoundsException("CharArray index out of range: "+start);
        if(end>)
            throw new IndexOutOfBoundsException("CharArray index out of range: "+end);
        if(start>end)
            throw new IndexOutOfBoundsException("CharArray index out of range: "+(end-start));
        return (start==0 && end==) ? this : CharBuffer.wrap(this.+startend-start);
    }
    @Override
    public String toString(){
        return new String();
    }
New to GrepCode? Check out our FAQ X