Source Code Cross Referenced for Cases.java in  » Science » jcm1-source » edu » hws » jcm » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » jcm1 source » edu.hws.jcm.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /*************************************************************************
02:         *                                                                        *
03:         *   1) This source code file, in unmodified form, and compiled classes   *
04:         *      derived from it can be used and distributed without restriction,  *
05:         *      including for commercial use.  (Attribution is not required       *
06:         *      but is appreciated.)                                              *
07:         *                                                                        *
08:         *    2) Modified versions of this file can be made and distributed       *
09:         *       provided:  the modified versions are put into a Java package     *
10:         *       different from the original package, edu.hws;  modified          *
11:         *       versions are distributed under the same terms as the original;   *
12:         *       and the modifications are documented in comments.  (Modification *
13:         *       here does not include simply making subclasses that belong to    *
14:         *       a package other than edu.hws, which can be done without any      *
15:         *       restriction.)                                                    *
16:         *                                                                        *
17:         *   David J. Eck                                                         *
18:         *   Department of Mathematics and Computer Science                       *
19:         *   Hobart and William Smith Colleges                                    *
20:         *   Geneva, New York 14456,   USA                                        *
21:         *   Email: eck@hws.edu          WWW: http://math.hws.edu/eck/            *
22:         *                                                                        *
23:         *************************************************************************/package edu.hws.jcm.data;
24:
25:        /**
26:         * An object of type Cases stores a list of "case values" that is generated
27:         * while an expression is being evaluated using the routine Expression.getValuesWithCases().
28:         * This information can be used as a heuristic (i.e. a fudge) to help detect
29:         * a possible discontinuity between two evaluations of the expression.  Suppose
30:         * that the expression is evaluated twice, with some change of variable values
31:         * between the two evaluations.  If the variables' values are not changed too much,
32:         * and if the Cases objects generated by the two evaluations are equal (as determined
33:         * by the "equals" method defined in this class), then it is likely that
34:         * there is no discontinuity.  (However, this is not perfect.  The discontinuity
35:         * in 1/x^2 won't be detected since the case value generated by 1/f(x) only
36:         * checks the sign of f(x), and the denominator of 1/x^2 is positive on both
37:         * sides of x=0.  If you want to be more paranoid, check both the expression
38:         * and its derivative.)  (I really don't like this very much, but it can be used to draw
39:         * pretty good graphs in general.)
40:         */
41:        public class Cases {
42:            private int[] cases = new int[1]; // Array of values that have been added with addCase(value).
43:            private int caseCt; // Number of items stored in cases array.
44:
45:            /**
46:             * Remove all the cases that have been added with addCase().
47:             * This makes it possible to reuse this object in another
48:             * call to Expression.getValueWithCases().
49:             */
50:            public void clear() {
51:                caseCt = 0;
52:            }
53:
54:            /**
55:             * Add a new case value to the list stored in this object.
56:             */
57:            public void addCase(int value) {
58:                if (caseCt == cases.length) {
59:                    int[] temp = new int[2 * caseCt];
60:                    System.arraycopy(cases, 0, temp, 0, caseCt);
61:                    cases = temp;
62:                }
63:                cases[caseCt++] = value;
64:            }
65:
66:            /**
67:             * Test whether c contains exactly the same list of case
68:             * values as this Cases object does.
69:             */
70:            public boolean equals(Cases c) {
71:                if (c.caseCt != caseCt)
72:                    return false;
73:                for (int i = 0; i < caseCt; i++)
74:                    if (c.cases[i] != cases[i])
75:                        return false;
76:                return true;
77:            }
78:
79:        } // end class Cases
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.