1+ //==============================================================================
2+ //
3+ // Copyright (c) 2019-
4+ // Authors:
5+ // * Steffen Maercker <steffen.maercker@tu-dresden.de> (TU Dresden)
6+ //
7+ //------------------------------------------------------------------------------
8+ //
9+ // This file is part of PRISM.
10+ //
11+ // PRISM is free software; you can redistribute it and/or modify
12+ // it under the terms of the GNU General Public License as published by
13+ // the Free Software Foundation; either version 2 of the License, or
14+ // (at your option) any later version.
15+ //
16+ // PRISM is distributed in the hope that it will be useful,
17+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
18+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+ // GNU General Public License for more details.
20+ //
21+ // You should have received a copy of the GNU General Public License
22+ // along with PRISM; if not, write to the Free Software Foundation,
23+ // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24+ //
25+ //==============================================================================
26+
27+ package explicit ;
28+
29+ import java .util .Iterator ;
30+ import java .util .Map ;
31+ import java .util .Map .Entry ;
32+
33+ import common .iterable .SingletonIterator ;
34+
35+ public class DiracDistribution implements Iterable <Entry <Integer , Double >>
36+ {
37+ private final Entry <Integer , Double > transition ;
38+
39+ public DiracDistribution (final int state )
40+ {
41+ this .transition = new Transition (state );
42+ }
43+
44+ public Iterator <Entry <Integer , Double >> iterator ()
45+ {
46+ return new SingletonIterator .Of <>(transition );
47+ }
48+
49+ public static Iterator <Entry <Integer , Double >> iterator (final int state )
50+ {
51+ return new SingletonIterator .Of <>((Entry <Integer , Double >) new Transition (state ));
52+ }
53+
54+ public static class Transition implements Map .Entry <Integer , Double >
55+ {
56+ private final Integer state ;
57+
58+ public Transition (final int state )
59+ {
60+ this .state = state ;
61+ }
62+
63+ @ Override
64+ public Integer getKey ()
65+ {
66+ return state ;
67+ }
68+
69+ @ Override
70+ public Double getValue ()
71+ {
72+ return 1.0 ;
73+ }
74+
75+ @ Override
76+ public Double setValue (final Double value )
77+ {
78+ throw new UnsupportedOperationException ("immutable entry" );
79+ }
80+ }
81+ }
0 commit comments