001/* Copyright (C) 2013 TU Dortmund 002 * This file is part of AutomataLib, http://www.automatalib.net/. 003 * 004 * AutomataLib is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Lesser General Public 006 * License version 3.0 as published by the Free Software Foundation. 007 * 008 * AutomataLib is distributed in the hope that it will be useful, 009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 011 * Lesser General Public License for more details. 012 * 013 * You should have received a copy of the GNU Lesser General Public 014 * License along with AutomataLib; if not, see 015 * http://www.gnu.de/documents/lgpl.en.html. 016 */ 017package net.automatalib.commons.util.collections; 018 019import java.util.ListIterator; 020 021public class CharRangeIterator implements ListIterator<Character> { 022 023 private final IntRangeIterator delegate; 024 025 public CharRangeIterator(char low, int step, int size) { 026 this(low, step, size, 0); 027 } 028 029 public CharRangeIterator(char low, int step, int size, int curr) { 030 this(new IntRangeIterator(low, step, size, curr)); 031 } 032 033 034 public CharRangeIterator(IntRangeIterator delegate) { 035 this.delegate = delegate; 036 } 037 038 @Override 039 public boolean hasNext() { 040 return delegate.hasNext(); 041 } 042 043 @Override 044 public Character next() { 045 return Character.valueOf((char)delegate.intNext()); 046 } 047 048 @Override 049 public boolean hasPrevious() { 050 return delegate.hasPrevious(); 051 } 052 053 @Override 054 public Character previous() { 055 return Character.valueOf((char)delegate.intPrevious()); 056 } 057 058 @Override 059 public int nextIndex() { 060 return delegate.nextIndex(); 061 } 062 063 @Override 064 public int previousIndex() { 065 return delegate.previousIndex(); 066 } 067 068 @Override 069 public void remove() { 070 throw new UnsupportedOperationException(); 071 } 072 073 @Override 074 public void set(Character e) { 075 throw new UnsupportedOperationException(); 076 } 077 078 @Override 079 public void add(Character e) { 080 throw new UnsupportedOperationException(); 081 } 082 083}