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.automata.base.compact;
018
019import net.automatalib.words.Alphabet;
020
021public class UniversalCompactSimpleDet<I, SP> extends
022                AbstractCompactSimpleDet<I, SP> {
023        
024        private Object[] stateProperties;
025        
026        
027
028        public UniversalCompactSimpleDet(Alphabet<I> alphabet, float resizeFactor) {
029                super(alphabet, resizeFactor);
030        }
031
032        public UniversalCompactSimpleDet(Alphabet<I> alphabet, int stateCapacity,
033                        float resizeFactor) {
034                super(alphabet, stateCapacity, resizeFactor);
035        }
036
037        public UniversalCompactSimpleDet(Alphabet<I> alphabet, int stateCapacity) {
038                super(alphabet, stateCapacity);
039        }
040
041        public UniversalCompactSimpleDet(Alphabet<I> alphabet) {
042                super(alphabet);
043        }
044
045        @Override
046        @SuppressWarnings("unchecked")
047        public SP getStateProperty(int stateId) {
048                return (SP)stateProperties[stateId];
049        }
050
051        @Override
052        public void initState(int stateId, SP property) {
053                stateProperties[stateId] = property;
054        }
055
056        @Override
057        public void setStateProperty(int stateId, SP property) {
058                stateProperties[stateId] = property;
059        }
060
061        @Override
062        protected void ensureCapacity(int oldCap, int newCap) {
063                super.ensureCapacity(oldCap, newCap);
064                Object[] newProps = new Object[newCap];
065                System.arraycopy(stateProperties, 0, newProps, 0, stateProperties.length);
066                stateProperties = newProps;
067        }
068
069        @Override
070        public void clear() {
071                super.clear();
072                for(int i = 0; i < stateProperties.length; i++)
073                        stateProperties[i] = null;
074        }
075        
076        
077
078}