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.graphs.base.compact;
018
019import net.automatalib.commons.util.array.ResizingObjectArray;
020
021public abstract class AbstractCompactNPGraph<E extends CompactEdge<EP>, NP, EP> 
022                extends AbstractCompactGraph<E, NP, EP> {
023
024        protected final ResizingObjectArray npStorage;
025        
026        public AbstractCompactNPGraph() {
027                this.npStorage = new ResizingObjectArray();
028        }
029        
030        @Override
031        @SuppressWarnings("unchecked")
032        public NP getNodeProperties(int node) {
033                return (NP)npStorage.array[node];
034        }
035
036        @Override
037        public void setNodeProperty(int node, NP property) {
038                npStorage.array[node] = property;
039        }
040
041        /* (non-Javadoc)
042         * @see net.automatalib.graphs.base.compact.AbstractCompactGraph#addIntNode(java.lang.Object)
043         */
044        @Override
045        public int addIntNode(NP properties) {
046                int node = super.addIntNode(properties);
047                npStorage.ensureCapacity(size);
048                npStorage.array[node] = properties;
049                return node;
050        }
051
052        
053
054        
055}