Source Code Cross Referenced for ChromosomePool.java in  » Development » jgap » org » jgap » impl » 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 » Development » jgap » org.jgap.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /*
02:         * This file is part of JGAP.
03:         *
04:         * JGAP offers a dual license model containing the LGPL as well as the MPL.
05:         *
06:         * For licensing information please see the file license.txt included with JGAP
07:         * or have a look at the top of class org.jgap.Chromosome which representatively
08:         * includes the JGAP license policy applicable for any file delivered with JGAP.
09:         */
10:        package org.jgap.impl;
11:
12:        import org.jgap.*;
13:
14:        /**
15:         * Provides a pooling mechanism for Chromosome instances so that
16:         * discarded Chromosome instances can be recycled, thus saving memory and the
17:         * overhead of constructing new ones from scratch each time.
18:         *
19:         * @author Neil Rotstan
20:         * @author Klaus Meffert
21:         * @since 1.0
22:         */
23:        public class ChromosomePool implements  IChromosomePool {
24:            /** String containing the CVS revision. Read out via reflection!*/
25:            private static final String CVS_REVISION = "$Revision: 1.12 $";
26:
27:            /**
28:             * The internal pool in which the Chromosomes are stored.
29:             */
30:            private Pool m_chromosomePool;
31:
32:            /**
33:             * Constructor.
34:             *
35:             * @author Neil Rostan
36:             * @since 1.0
37:             */
38:            public ChromosomePool() {
39:                m_chromosomePool = new Pool();
40:            }
41:
42:            /**
43:             * Attempts to acquire an Chromosome instance from the chromosome pool.
44:             * It should be noted that nothing is guaranteed about the value of the
45:             * Chromosome's genes and they should be treated as undefined.
46:             *
47:             * @return a Chromosome instance from the pool or null if no Chromosome
48:             * instances are available in the pool
49:             *
50:             * @author Neil Rostan
51:             * @since 1.0
52:             */
53:            public synchronized IChromosome acquireChromosome() {
54:                return (IChromosome) m_chromosomePool.acquirePooledObject();
55:            }
56:
57:            /**
58:             * Releases a Chromosome to the pool. It's not required that the Chromosome
59:             * originated from the pool--any Chromosome can be released to it. This
60:             * method will invoke the cleanup() method on each of the Chromosome's
61:             * genes prior to adding it back to the pool.
62:             *
63:             * @param a_chromosome the Chromosome instance to be released into the pool
64:             *
65:             * @author Neil Rostan
66:             * @since 1.0
67:             */
68:            public synchronized void releaseChromosome(
69:                    final IChromosome a_chromosome) {
70:                if (a_chromosome == null) {
71:                    throw new IllegalArgumentException(
72:                            "Chromosome instance must not be null!");
73:                }
74:                // First cleanup the chromosome's genes before returning it back
75:                // to the pool.
76:                // -------------------------------------------------------------
77:                Gene[] genes = a_chromosome.getGenes();
78:                int size = a_chromosome.size();
79:                for (int i = 0; i < size; i++) {
80:                    genes[i].cleanup();
81:                }
82:                // Now add it to the pool.
83:                // -----------------------
84:                m_chromosomePool.releaseObject(a_chromosome);
85:            }
86:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.