| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| NodeMapAsDoubleNodeMap |
|
| 0.0;0 |
| 1 | /* | |
| 2 | This file is part of Combean. | |
| 3 | ||
| 4 | Combean is free software; you can redistribute it and/or modify | |
| 5 | it under the terms of the GNU General Public License as published by | |
| 6 | the Free Software Foundation; either version 2 of the License, or | |
| 7 | (at your option) any later version. | |
| 8 | ||
| 9 | Combean is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | GNU General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU General Public License | |
| 15 | along with Combean; if not, write to the Free Software | |
| 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 17 | */ | |
| 18 | /* | |
| 19 | * Created on 13.08.2005 | |
| 20 | * | |
| 21 | */ | |
| 22 | package net.sourceforge.combean.graph.containers.doubleval; | |
| 23 | ||
| 24 | import net.sourceforge.combean.graph.containers.MapAsNodeMap; | |
| 25 | import net.sourceforge.combean.interfaces.graph.Graph; | |
| 26 | import net.sourceforge.combean.interfaces.graph.Node; | |
| 27 | import net.sourceforge.combean.interfaces.graph.containers.NodeMap; | |
| 28 | import net.sourceforge.combean.interfaces.graph.containers.doubleval.DoubleNodeMap; | |
| 29 | ||
| 30 | /** | |
| 31 | * Use a 'normal' NodeMap as DoubleNodeMap | |
| 32 | * | |
| 33 | * @author schickin | |
| 34 | * | |
| 35 | */ | |
| 36 | public class NodeMapAsDoubleNodeMap implements DoubleNodeMap { | |
| 37 | ||
| 38 | 30 | private NodeMap<Double> nodeMap = null; |
| 39 | ||
| 40 | /** | |
| 41 | * Default constructor. Wraps a MapAsNodeMap. | |
| 42 | */ | |
| 43 | public NodeMapAsDoubleNodeMap() { | |
| 44 | 30 | super(); |
| 45 | ||
| 46 | 30 | this.nodeMap = new MapAsNodeMap<Double>(); |
| 47 | 30 | } |
| 48 | ||
| 49 | /** | |
| 50 | * Constructor. Wraps a given NodeMap. | |
| 51 | * | |
| 52 | * @param nodeMap the NodeMap to be wrapped. | |
| 53 | */ | |
| 54 | public NodeMapAsDoubleNodeMap(NodeMap<Double> nodeMap) { | |
| 55 | 0 | super(); |
| 56 | ||
| 57 | 0 | this.nodeMap = nodeMap; |
| 58 | 0 | } |
| 59 | ||
| 60 | /* (non-Javadoc) | |
| 61 | * @see net.sourceforge.combean.interfaces.graph.containers.DoubleNodeMap#putDouble(net.sourceforge.combean.interfaces.graph.Node, double) | |
| 62 | */ | |
| 63 | public double putDouble(Node v, double newVal) { | |
| 64 | 132 | return (this.nodeMap.put(v, new Double(newVal))).doubleValue(); |
| 65 | } | |
| 66 | ||
| 67 | /* (non-Javadoc) | |
| 68 | * @see net.sourceforge.combean.interfaces.graph.containers.NodeMap#init(net.sourceforge.combean.interfaces.graph.Graph) | |
| 69 | */ | |
| 70 | public void init(Graph g) { | |
| 71 | 30 | this.nodeMap.init(g, new Double(0)); |
| 72 | 30 | } |
| 73 | ||
| 74 | /* (non-Javadoc) | |
| 75 | * @see net.sourceforge.combean.interfaces.graph.containers.InitializableWithDoubleDefaultValue#init(net.sourceforge.combean.interfaces.graph.Graph, double) | |
| 76 | */ | |
| 77 | public void init(Graph g, double initVal) { | |
| 78 | 0 | this.nodeMap.init(g, new Double(initVal)); |
| 79 | 0 | } |
| 80 | ||
| 81 | /* (non-Javadoc) | |
| 82 | * @see net.sourceforge.combean.interfaces.graph.containers.FixedDoubleNodeMap#getDouble(net.sourceforge.combean.interfaces.graph.Node) | |
| 83 | */ | |
| 84 | public double getDouble(Node v) { | |
| 85 | 126 | return (this.nodeMap.get(v)).doubleValue(); |
| 86 | } | |
| 87 | ||
| 88 | /* (non-Javadoc) | |
| 89 | * @see net.sourceforge.combean.interfaces.graph.containers.Clearable#clear() | |
| 90 | */ | |
| 91 | public void clear() { | |
| 92 | 0 | this.nodeMap.clear(); |
| 93 | 0 | } |
| 94 | } |