You can subscribe to this list here.
2002 |
Jan
(14) |
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
(3) |
Jul
(3) |
Aug
(6) |
Sep
(14) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(1) |
Feb
|
Mar
(7) |
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
(2) |
Sep
(3) |
Oct
|
Nov
(7) |
Dec
(3) |
2004 |
Jan
|
Feb
(3) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
|
2005 |
Jan
|
Feb
|
Mar
(11) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(7) |
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(29) |
Dec
(16) |
2007 |
Jan
(11) |
Feb
(6) |
Mar
(12) |
Apr
(2) |
May
|
Jun
(16) |
Jul
(9) |
Aug
(5) |
Sep
|
Oct
(4) |
Nov
(8) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
(23) |
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
(11) |
Nov
(2) |
Dec
(3) |
2009 |
Jan
|
Feb
(2) |
Mar
(15) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(65) |
Sep
(180) |
Oct
(52) |
Nov
(33) |
Dec
|
2010 |
Jan
(5) |
Feb
(3) |
Mar
(24) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(49) |
Oct
|
Nov
|
Dec
|
From: Jeff R. <uph...@us...> - 2009-09-14 19:02:34
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/impl In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6715/src/gnu/trove/impl Modified Files: Tag: TROVE_3_WORKING Constants.java Log Message: Interface and Implementation for TObjectPrimitiveHashMaps, associated tests, and related changes Index: Constants.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/impl/Attic/Constants.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** Constants.java 2 Sep 2009 21:52:33 -0000 1.1.2.3 --- Constants.java 14 Sep 2009 19:02:20 -0000 1.1.2.4 *************** *** 38,40 **** --- 38,61 ---- // /** flag indicating that the value of a slot in the hashtable was deleted */ // public static final byte SLOT_REMOVED = 2; + + /** the default value that represents for <tt>byte</tt> types. */ + public static final int DEFAULT_BYTE_NO_ENTRY_VALUE = 0; + + /** the default value that represents for <tt>short</tt> types. */ + public static final int DEFAULT_SHORT_NO_ENTRY_VALUE = 0; + + /** the default value that represents for <tt>char</tt> types. */ + public static final int DEFAULT_CHAR_NO_ENTRY_VALUE = 0; + + /** the default value that represents for <tt>int</tt> types. */ + public static final int DEFAULT_INT_NO_ENTRY_VALUE = 0; + + /** the default value that represents for <tt>long</tt> types. */ + public static final int DEFAULT_LONG_NO_ENTRY_VALUE = 0; + + /** the default value that represents for <tt>float</tt> types. */ + public static final int DEFAULT_FLOAT_NO_ENTRY_VALUE = 0; + + /** the default value that represents for <tt>double</tt> types. */ + public static final int DEFAULT_DOUBLE_NO_ENTRY_VALUE = 0; } |
From: Jeff R. <uph...@us...> - 2009-09-14 19:02:34
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6715/templates/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING _K__V_HashMap.template Added Files: Tag: TROVE_3_WORKING Object_E_HashMap.template Log Message: Interface and Implementation for TObjectPrimitiveHashMaps, associated tests, and related changes --- NEW FILE: Object_E_HashMap.template --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2001, Eric D. Friedman All Rights Reserved. // Copyright (c) 2009, Rob Eden All Rights Reserved. // Copyright (c) 2009, Jeff Randall All Rights Reserved. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// [...1087 lines suppressed...] } /** {@inheritDoc} */ public String toString() { final StringBuilder buf = new StringBuilder("{"); forEachEntry( new TObject#E#Procedure<K>() { private boolean first = true; public boolean execute( K key, #e# value ) { if ( first ) first = false; else buf.append( "," ); buf.append( key ).append( "=" ).append( value ); return true; } }); buf.append( "}" ); return buf.toString(); } } // TObject#E#HashMap Index: _K__V_HashMap.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/map/hash/Attic/_K__V_HashMap.template,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** _K__V_HashMap.template 11 Sep 2009 22:20:48 -0000 1.1.2.4 --- _K__V_HashMap.template 14 Sep 2009 19:02:20 -0000 1.1.2.5 *************** *** 1157,1164 **** @Override public boolean equals( Object other ) { ! if ( !( other instanceof T#V#Set ) ) { return false; } ! final T#V#Set that = ( T#V#Set ) other; if ( that.size() != this.size() ) { return false; --- 1157,1164 ---- @Override public boolean equals( Object other ) { ! if ( !( other instanceof T#V#Collection ) ) { return false; } ! final T#V#Collection that = ( T#V#Collection ) other; if ( that.size() != this.size() ) { return false; |
From: Jeff R. <uph...@us...> - 2009-09-14 19:02:31
|
Update of /cvsroot/trove4j/trove/generator_src/gnu/trove/generator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6715/generator_src/gnu/trove/generator Modified Files: Tag: TROVE_3_WORKING Generator.java Log Message: Interface and Implementation for TObjectPrimitiveHashMaps, associated tests, and related changes Index: Generator.java =================================================================== RCS file: /cvsroot/trove4j/trove/generator_src/gnu/trove/generator/Attic/Generator.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -C2 -d -r1.1.2.6 -r1.1.2.7 *** Generator.java 14 Sep 2009 04:10:31 -0000 1.1.2.6 --- Generator.java 14 Sep 2009 19:02:19 -0000 1.1.2.7 *************** *** 45,48 **** --- 45,49 ---- private static final Pattern PATTERN_v; private static final Pattern PATTERN_V; + private static final Pattern PATTERN_VC; private static final Pattern PATTERN_VT; private static final Pattern PATTERN_VMAX; *************** *** 52,55 **** --- 53,57 ---- private static final Pattern PATTERN_k; private static final Pattern PATTERN_K; + private static final Pattern PATTERN_KC; private static final Pattern PATTERN_KT; private static final Pattern PATTERN_KMAX; *************** *** 59,62 **** --- 61,65 ---- private static final Pattern PATTERN_e; private static final Pattern PATTERN_E; + private static final Pattern PATTERN_EC; private static final Pattern PATTERN_ET; private static final Pattern PATTERN_EMAX; *************** *** 67,70 **** --- 70,74 ---- PATTERN_v = Pattern.compile( "#v#" ); PATTERN_V = Pattern.compile( "#V#" ); + PATTERN_VC = Pattern.compile( "#VC#" ); PATTERN_VT = Pattern.compile( "#VT#" ); PATTERN_VMAX = Pattern.compile( "#VMAX#" ); *************** *** 74,77 **** --- 78,82 ---- PATTERN_k = Pattern.compile( "#k#" ); PATTERN_K = Pattern.compile( "#K#" ); + PATTERN_KC = Pattern.compile( "#KC#" ); PATTERN_KT = Pattern.compile( "#KT#" ); PATTERN_KMAX = Pattern.compile( "#KMAX#" ); *************** *** 81,84 **** --- 86,90 ---- PATTERN_e = Pattern.compile( "#e#" ); PATTERN_E = Pattern.compile( "#E#" ); + PATTERN_EC = Pattern.compile( "#EC#" ); PATTERN_ET = Pattern.compile( "#ET#" ); PATTERN_EMAX = Pattern.compile( "#EMAX#" ); *************** *** 187,190 **** --- 193,197 ---- String KT = info.class_name; String K = abbreviate( KT ); + String KC = K.toUpperCase(); String KMAX = info.max_value; String KMIN = info.min_value; *************** *** 193,196 **** --- 200,204 ---- out = PATTERN_k.matcher( out ).replaceAll( k ); out = PATTERN_K.matcher( out ).replaceAll( K ); + out = PATTERN_KC.matcher( out ).replaceAll( KC ); out = PATTERN_KT.matcher( out ).replaceAll( KT ); out = PATTERN_KMAX.matcher( out ).replaceAll( KMAX ); *************** *** 204,207 **** --- 212,216 ---- String VT = jinfo.class_name; String V = abbreviate( VT ); + String VC = V.toUpperCase(); String VMAX = jinfo.max_value; String VMIN = jinfo.min_value; *************** *** 211,214 **** --- 220,224 ---- vout = PATTERN_v.matcher( vout ).replaceAll( v ); vout = PATTERN_V.matcher( vout ).replaceAll( V ); + vout = PATTERN_VC.matcher( vout ).replaceAll( VC ); vout = PATTERN_VT.matcher( vout ).replaceAll( VT ); vout = PATTERN_VMAX.matcher( vout ).replaceAll( VMAX ); *************** *** 239,242 **** --- 249,253 ---- String ET = info.class_name; String E = abbreviate( ET ); + String EC = E.toUpperCase(); String EMAX = info.max_value; String EMIN = info.min_value; *************** *** 245,248 **** --- 256,260 ---- out = PATTERN_e.matcher( out ).replaceAll( e ); out = PATTERN_E.matcher( out ).replaceAll( E ); + out = PATTERN_EC.matcher( out ).replaceAll( EC ); out = PATTERN_ET.matcher( out ).replaceAll( ET ); out = PATTERN_EMAX.matcher( out ).replaceAll( EMAX ); |
From: Rob E. <ro...@us...> - 2009-09-14 04:10:41
|
Update of /cvsroot/trove4j/trove/generator_test/gnu/trove/generator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3144/trove/generator_test/gnu/trove/generator Added Files: Tag: TROVE_3_WORKING GeneratorTest.java Log Message: Support for replication in Generator (with unit tests). Stubbed out TDecorators class (previously just called "Decorators"). --- NEW FILE: GeneratorTest.java --- /* * /////////////////////////////////////////////////////////////////////////////// * // Copyright (c) 2009, Rob Eden All Rights Reserved. * // * // This library is free software; you can redistribute it and/or * // modify it under the terms of the GNU Lesser General Public * // License as published by the Free Software Foundation; either * // version 2.1 of the License, or (at your option) any later version. * // * // This library is distributed in the hope that it will be useful, * // but WITHOUT ANY WARRANTY; without even the implied warranty of * // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * // GNU General Public License for more details. * // * // You should have received a copy of the GNU Lesser General Public * // License along with this program; if not, write to the Free Software * // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * /////////////////////////////////////////////////////////////////////////////// */ package gnu.trove.generator; import junit.framework.TestCase; import java.io.IOException; import java.util.HashMap; import java.util.Map; /** * */ public class GeneratorTest extends TestCase { public void testReplicatedContentNoMatch() throws IOException { String test = "This is a test\nLine 2\nLine 3"; StringBuilder buf = new StringBuilder(); assertNull( Generator.findReplicatedBlocks( test, buf ) ); assertEquals( 0, buf.length() ); } public void testReplicatedContent() throws IOException { String test = "This is a test\nLine 2\n====START_REPLICATED_CONTENT #1====\n" + "Replicated 1\n=====END_REPLICATED_CONTENT #1=====\n" + "====START_REPLICATED_CONTENT #2====\n" + "Replicated 2\n=====END_REPLICATED_CONTENT #2=====\n"; StringBuilder buf = new StringBuilder(); Map<Integer,String> map = Generator.findReplicatedBlocks( test, buf ); assertNotNull( map ); assertEquals( 2, map.size() ); assertEquals( "Replicated 1", map.get( Integer.valueOf( 1 ) ) ); assertEquals( "Replicated 2", map.get( Integer.valueOf( 2 ) ) ); assertEquals( "This is a test\nLine 2", buf.toString() ); } public void testProcessReplication() { String test = "Line 1\n#REPLICATED1#\n#REPLICATED2#\nLine 4"; Map<Integer,String> map = new HashMap<Integer,String>(); map.put( Integer.valueOf( 1 ), "Line 2 - #E#" ); map.put( Integer.valueOf( 2 ), "Line 3 - #K# #V#" ); String output = Generator.processReplication( test, map ); // new WrapperInfo( "double", "Double", "POSITIVE_INFINITY", "NEGATIVE_INFINITY" ), // new WrapperInfo( "float", "Float", "POSITIVE_INFINITY", "NEGATIVE_INFINITY" ), // new WrapperInfo( "int", "Integer", "MAX_VALUE", "MIN_VALUE" ), // new WrapperInfo( "long", "Long", "MAX_VALUE", "MIN_VALUE" ), // new WrapperInfo( "byte", "Byte", "MAX_VALUE", "MIN_VALUE" ), // new WrapperInfo( "short", "Short", "MAX_VALUE", "MIN_VALUE" ), // new WrapperInfo( "char", "Character", "MAX_VALUE", "MIN_VALUE" ) }; String goal = "Line 1\n" + "Line 2 - Double\n\n" + "Line 2 - Float\n\n" + "Line 2 - Int\n\n" + "Line 2 - Long\n\n" + "Line 2 - Byte\n\n" + "Line 2 - Short\n\n" + "Line 2 - Char\n" + "Line 3 - Double Double\n\n" + "Line 3 - Double Float\n\n" + "Line 3 - Double Int\n\n" + "Line 3 - Double Long\n\n" + "Line 3 - Double Byte\n\n" + "Line 3 - Double Short\n\n" + "Line 3 - Double Char\n\n" + "Line 3 - Float Double\n\n" + "Line 3 - Float Float\n\n" + "Line 3 - Float Int\n\n" + "Line 3 - Float Long\n\n" + "Line 3 - Float Byte\n\n" + "Line 3 - Float Short\n\n" + "Line 3 - Float Char\n\n" + "Line 3 - Int Double\n\n" + "Line 3 - Int Float\n\n" + "Line 3 - Int Int\n\n" + "Line 3 - Int Long\n\n" + "Line 3 - Int Byte\n\n" + "Line 3 - Int Short\n\n" + "Line 3 - Int Char\n\n" + "Line 3 - Long Double\n\n" + "Line 3 - Long Float\n\n" + "Line 3 - Long Int\n\n" + "Line 3 - Long Long\n\n" + "Line 3 - Long Byte\n\n" + "Line 3 - Long Short\n\n" + "Line 3 - Long Char\n\n" + "Line 3 - Byte Double\n\n" + "Line 3 - Byte Float\n\n" + "Line 3 - Byte Int\n\n" + "Line 3 - Byte Long\n\n" + "Line 3 - Byte Byte\n\n" + "Line 3 - Byte Short\n\n" + "Line 3 - Byte Char\n\n" + "Line 3 - Short Double\n\n" + "Line 3 - Short Float\n\n" + "Line 3 - Short Int\n\n" + "Line 3 - Short Long\n\n" + "Line 3 - Short Byte\n\n" + "Line 3 - Short Short\n\n" + "Line 3 - Short Char\n\n" + "Line 3 - Char Double\n\n" + "Line 3 - Char Float\n\n" + "Line 3 - Char Int\n\n" + "Line 3 - Char Long\n\n" + "Line 3 - Char Byte\n\n" + "Line 3 - Char Short\n\n" + "Line 3 - Char Char\n" + "Line 4"; assertEquals( goal, output ); } } |
From: Rob E. <ro...@us...> - 2009-09-14 04:10:41
|
Update of /cvsroot/trove4j/trove/generator_src/gnu/trove/generator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3144/trove/generator_src/gnu/trove/generator Modified Files: Tag: TROVE_3_WORKING Generator.java Log Message: Support for replication in Generator (with unit tests). Stubbed out TDecorators class (previously just called "Decorators"). Index: Generator.java =================================================================== RCS file: /cvsroot/trove4j/trove/generator_src/gnu/trove/generator/Attic/Generator.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** Generator.java 14 Sep 2009 01:27:51 -0000 1.1.2.5 --- Generator.java 14 Sep 2009 04:10:31 -0000 1.1.2.6 *************** *** 25,28 **** --- 25,30 ---- import java.security.NoSuchAlgorithmException; import java.util.Arrays; + import java.util.HashMap; + import java.util.Map; import java.util.regex.Pattern; *************** *** 154,158 **** file_name = file_name.replaceAll( "\\.template", ".java" ); ! // See what kind of template markers it's using, either e or k/v if ( file_name.contains( "_K_" ) ) { processKVMarkers( content, output_directory, file_name ); --- 156,162 ---- file_name = file_name.replaceAll( "\\.template", ".java" ); ! ! // See what kind of template markers it's using, either e or k/v. No marker ! // indicates a replication-only class. if ( file_name.contains( "_K_" ) ) { processKVMarkers( content, output_directory, file_name ); *************** *** 161,164 **** --- 165,180 ---- processEMarkers( content, output_directory, file_name ); } + else { + // Replication only + StringBuilder processed_replication_output = new StringBuilder(); + Map<Integer,String> replicated_blocks = + findReplicatedBlocks( content, processed_replication_output ); + if ( replicated_blocks != null ) { + content = processReplication( processed_replication_output.toString(), + replicated_blocks ); + } + + writeFile( content, new File( output_directory, file_name ) ); + } } *************** *** 197,204 **** vout = PATTERN_VT.matcher( vout ).replaceAll( VT ); vout = PATTERN_VMAX.matcher( vout ).replaceAll( VMAX ); ! vout = PATTERN_VMIN.matcher( vout ).replaceAll( VMIN ); ! writeFile( vout, new File( output_dir, ! PATTERN_V_UNDERBAR.matcher( out_file_name ).replaceAll( V ) ) ); } } --- 213,230 ---- vout = PATTERN_VT.matcher( vout ).replaceAll( VT ); vout = PATTERN_VMAX.matcher( vout ).replaceAll( VMAX ); ! String processed_output = PATTERN_VMIN.matcher( vout ).replaceAll( VMIN ); ! StringBuilder processed_replication_output = new StringBuilder(); ! Map<Integer,String> replicated_blocks = ! findReplicatedBlocks( processed_output, processed_replication_output ); ! if ( replicated_blocks != null ) { ! processed_output = processReplication( ! processed_replication_output.toString(), replicated_blocks ); ! } ! ! String processed_filename = ! PATTERN_V_UNDERBAR.matcher( out_file_name ).replaceAll( V ); ! ! writeFile( processed_output, new File( output_dir, processed_filename ) ); } } *************** *** 221,235 **** out = PATTERN_ET.matcher( out ).replaceAll( ET ); out = PATTERN_EMAX.matcher( out ).replaceAll( EMAX ); ! out = PATTERN_EMIN.matcher( out ).replaceAll( EMIN ); String out_file_name = "T" + file_name; out_file_name = PATTERN_E_UNDERBAR.matcher( out_file_name ).replaceAll( E ); ! writeFile( out, new File( output_dir, out_file_name ) ); } } private static void writeFile( String content, File output_file ) throws IOException { --- 247,338 ---- out = PATTERN_ET.matcher( out ).replaceAll( ET ); out = PATTERN_EMAX.matcher( out ).replaceAll( EMAX ); ! String processed_output = PATTERN_EMIN.matcher( out ).replaceAll( EMIN ); String out_file_name = "T" + file_name; out_file_name = PATTERN_E_UNDERBAR.matcher( out_file_name ).replaceAll( E ); + StringBuilder processed_replication_output = new StringBuilder(); + Map<Integer,String> replicated_blocks = + findReplicatedBlocks( processed_output, processed_replication_output ); + if ( replicated_blocks != null ) { + processed_output = processReplication( + processed_replication_output.toString(), replicated_blocks ); + } ! writeFile( processed_output, new File( output_dir, out_file_name ) ); } } + static String processReplication( String content, + Map<Integer, String> replicated_blocks ) { + + for ( Map.Entry<Integer, String> entry : replicated_blocks.entrySet() ) { + // Replace the markers in the replicated content + + StringBuilder entry_buffer = new StringBuilder(); + + boolean first_loop = true; + for ( int i = 0; i < WRAPPERS.length; i++ ) { + WrapperInfo info = WRAPPERS[i]; + + String k = info.primitive; + String KT = info.class_name; + String K = abbreviate( KT ); + String KMAX = info.max_value; + String KMIN = info.min_value; + + for ( int j = 0; j < WRAPPERS.length; j++ ) { + WrapperInfo jinfo = WRAPPERS[j]; + + String v = jinfo.primitive; + String VT = jinfo.class_name; + String V = abbreviate( VT ); + String VMAX = jinfo.max_value; + String VMIN = jinfo.min_value; + + String out = entry.getValue(); + String before_e = out; + out = Pattern.compile( "#e#" ).matcher( out ).replaceAll( k ); + out = Pattern.compile( "#E#" ).matcher( out ).replaceAll( K ); + out = Pattern.compile( "#ET#" ).matcher( out ).replaceAll( KT ); + out = Pattern.compile( "#EMAX#" ).matcher( out ).replaceAll( KMAX ); + out = Pattern.compile( "#EMIN#" ).matcher( out ).replaceAll( KMIN ); + boolean uses_e = !out.equals( before_e ); + + // If we use "e" (instead of "k" & "v", then we don't need the inner + // map. Yeah, this is ugly I know... but it works. + if ( uses_e && j != 0 ) break; + + out = Pattern.compile( "#v#" ).matcher( out ).replaceAll( v ); + out = Pattern.compile( "#V#" ).matcher( out ).replaceAll( V ); + out = Pattern.compile( "#VT#" ).matcher( out ).replaceAll( VT ); + out = Pattern.compile( "#VMAX#" ).matcher( out ).replaceAll( VMAX ); + out = Pattern.compile( "#VMIN#" ).matcher( out ).replaceAll( VMIN ); + + out = Pattern.compile( "#k#" ).matcher( out ).replaceAll( k ); + out = Pattern.compile( "#K#" ).matcher( out ).replaceAll( K ); + out = Pattern.compile( "#KT#" ).matcher( out ).replaceAll( KT ); + out = Pattern.compile( "#KMAX#" ).matcher( out ).replaceAll( KMAX ); + out = Pattern.compile( "#KMIN#" ).matcher( out ).replaceAll( KMIN ); + + if ( first_loop ) first_loop = false; + else { + entry_buffer.append( System.getProperty( "line.separator" ) ); + entry_buffer.append( System.getProperty( "line.separator" ) ); + } + + entry_buffer.append( out ); + } + } + + content = Pattern.compile( "#REPLICATED" + entry.getKey() + "#" ).matcher( + content ).replaceAll( entry_buffer.toString() ); + } + + return content; + } + + private static void writeFile( String content, File output_file ) throws IOException { *************** *** 355,358 **** --- 458,525 ---- + /** + * Find replicated block definitions at the end of content. + * + * @param content_in The content + * @param content_out A StringBuffer into which the content (without the + * definition blocks is placed). This will be untouched + * if no definition blocks are found. + * + * @return Null if no definition blocks are found, otherwise a map + * containing the blocks, keyed by their number. + */ + static Map<Integer,String> findReplicatedBlocks( String content_in, + StringBuilder content_out ) throws IOException { + + Map<Integer,String> to_return = null; + + // Find the replicated content blocks in the template. For ease, read this line + // by line. + BufferedReader reader = new BufferedReader( new StringReader( content_in ) ); + String line; + StringBuilder buffer = new StringBuilder(); + boolean in_replicated_block = false; + boolean need_newline = false; + while ( ( line = reader.readLine() ) != null ) { + if ( !in_replicated_block && + line.startsWith( "====START_REPLICATED_CONTENT #" ) ) { + + in_replicated_block = true; + need_newline = false; + + if ( content_out.length() == 0 ) { + content_out.append( buffer.toString() ); + } + + buffer = new StringBuilder(); + } + else if ( in_replicated_block && + line.startsWith( "=====END_REPLICATED_CONTENT #" ) ) { + int number_start_index = "=====END_REPLICATED_CONTENT #".length(); + int number_end_index = line.indexOf( "=", number_start_index ); + + String number = line.substring( number_start_index, number_end_index ); + Integer number_obj = Integer.valueOf( number ); + + if ( to_return == null ) to_return = new HashMap<Integer,String>(); + to_return.put( number_obj, buffer.toString() ); + + in_replicated_block = false; + need_newline = false; + } + else { + if ( need_newline ) { + buffer.append( System.getProperty( "line.separator" ) ); + } + else need_newline = true; + + buffer.append( line ); + } + } + + return to_return; + } + + private static String simplifyPath( File file ) { String output_string = root_output_dir.toString(); |
From: Rob E. <ro...@us...> - 2009-09-14 04:10:40
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3144/trove/templates/gnu/trove Added Files: Tag: TROVE_3_WORKING TDecorators.template Log Message: Support for replication in Generator (with unit tests). Stubbed out TDecorators class (previously just called "Decorators"). --- NEW FILE: TDecorators.template --- /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2008, Robert D. Eden All Rights Reserved. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// package gnu.trove; import java.util.*; import gnu.trove.map.*; /** * This is a static utility class that provides functions for simplifying creation of * decorators. * * @author Robert D. Eden * @since Trove 2.1 */ public class TDecorators { // Hide the constructor private TDecorators() {} #REPLICATED1# #REPLICATED2# #REPLICATED3# #REPLICATED4# } ====START_REPLICATED_CONTENT #1==== /** * Wrap the given map in a decorator that uses the standard {@link java.util.Map Map} * interface. */ // public static Map<#KT#,#VT#> wrap( T#K##V#Map map ) { // return new T#K##V#MapDecorator( map ); // } =====END_REPLICATED_CONTENT #1===== ====START_REPLICATED_CONTENT #2==== /** * Wrap the given map in a decorator that uses the standard {@link java.util.Map Map} * interface. */ // public static <T> Map<T,#ET#> wrap( TObject#E#Map<T> map ) { // return new TObject#E#MapDecorator<T>( map ); // } =====END_REPLICATED_CONTENT #2===== ====START_REPLICATED_CONTENT #3==== /** * Wrap the given map in a decorator that uses the standard {@link java.util.Map Map} * interface. */ // public static <T> Map<#ET#,T> wrap( T#E#ObjectMap<T> map ) { // return new T#E#ObjectMapDecorator<T>( map ); // } =====END_REPLICATED_CONTENT #3===== ====START_REPLICATED_CONTENT #4==== /** * Wrap the given set in a decorator that uses the standard {@link java.util.Set Set} * interface. */ // public static Set<#ET#> wrap( T#E#Set set ) { // return new T#E#SetDecorator( set ); // } =====END_REPLICATED_CONTENT #4===== |
From: Rob E. <ro...@us...> - 2009-09-14 02:48:23
|
Update of /cvsroot/trove4j/trove/generator_test/gnu/trove/generator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27210/trove/generator_test/gnu/trove/generator Log Message: Directory /cvsroot/trove4j/trove/generator_test/gnu/trove/generator added to the repository |
From: Rob E. <ro...@us...> - 2009-09-14 02:48:20
|
Update of /cvsroot/trove4j/trove/generator_test/gnu/trove In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27196/trove/generator_test/gnu/trove Log Message: Directory /cvsroot/trove4j/trove/generator_test/gnu/trove added to the repository |
From: Rob E. <ro...@us...> - 2009-09-14 02:48:13
|
Update of /cvsroot/trove4j/trove/generator_test/gnu In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27134/trove/generator_test/gnu Log Message: Directory /cvsroot/trove4j/trove/generator_test/gnu added to the repository |
From: Rob E. <ro...@us...> - 2009-09-14 02:48:06
|
Update of /cvsroot/trove4j/trove/generator_test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27121/trove/generator_test Log Message: Directory /cvsroot/trove4j/trove/generator_test added to the repository |
From: Rob E. <ro...@us...> - 2009-09-14 01:28:11
|
Update of /cvsroot/trove4j/trove/generator_src/gnu/trove/generator In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv19815/trove/generator_src/gnu/trove/generator Modified Files: Tag: TROVE_3_WORKING Generator.java Log Message: Ignore CVS directories, move check for hidden File objects before directory check. Index: Generator.java =================================================================== RCS file: /cvsroot/trove4j/trove/generator_src/gnu/trove/generator/Attic/Generator.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** Generator.java 19 Aug 2009 05:46:00 -0000 1.1.2.4 --- Generator.java 14 Sep 2009 01:27:51 -0000 1.1.2.5 *************** *** 128,139 **** File[] files = input_directory.listFiles(); for ( File file : files ) { if ( file.isDirectory() ) { scanForFiles( file, new File( output_directory, file.getName() ) ); continue; } - // Ignore hidden files - if ( file.isHidden() ) continue; - processFile( file, output_directory ); } --- 128,142 ---- File[] files = input_directory.listFiles(); for ( File file : files ) { + // Ignore hidden files + if ( file.isHidden() ) continue; + if ( file.isDirectory() ) { + // Ignore CVS directories + if ( file.getName().equals( "CVS" ) ) continue; + scanForFiles( file, new File( output_directory, file.getName() ) ); continue; } processFile( file, output_directory ); } |
From: Jeff R. <uph...@us...> - 2009-09-11 22:21:02
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/impl/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22836/templates/gnu/trove/impl/hash Modified Files: Tag: TROVE_3_WORKING _K__V_Hash.template Log Message: Full test coverage for TPrimitivePrimitiveHashMaps, changes associated with test implemenation Index: _K__V_Hash.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/impl/hash/Attic/_K__V_Hash.template,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** _K__V_Hash.template 8 Sep 2009 16:26:40 -0000 1.1.2.1 --- _K__V_Hash.template 11 Sep 2009 22:20:48 -0000 1.1.2.2 *************** *** 198,202 **** */ public void removeAt( int index ) { ! _set[index] = ( #k# ) no_entry_value; super.removeAt( index ); } --- 198,202 ---- */ public void removeAt( int index ) { ! _set[index] = no_entry_key; super.removeAt( index ); } |
From: Jeff R. <uph...@us...> - 2009-09-11 22:21:01
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22836/templates/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING _K__V_HashMap.template Log Message: Full test coverage for TPrimitivePrimitiveHashMaps, changes associated with test implemenation Index: _K__V_HashMap.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/map/hash/Attic/_K__V_HashMap.template,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** _K__V_HashMap.template 9 Sep 2009 01:15:54 -0000 1.1.2.3 --- _K__V_HashMap.template 11 Sep 2009 22:20:48 -0000 1.1.2.4 *************** *** 250,254 **** /** ! * Put all the entries from the given T#K##V#map into this map. * * @param map The map from which entries will be obtained to put into this map. --- 250,254 ---- /** ! * Put all the entries from the given T#K##V#Map into this map. * * @param map The map from which entries will be obtained to put into this map. *************** *** 256,268 **** public void putAll( T#K##V#Map map ) { ensureCapacity( map.size() ); ! if ( map instanceof T#K##V#HashMap ) { ! T#K##V#HashMap hmap = ( T#K##V#HashMap ) map; ! for ( int i = hmap._states.length; i-- > 0; ) { ! if ( hmap._states[i] == FULL ) { ! this.put( hmap._set[i], hmap._values[i] ); ! } ! } ! } else { ! throw new UnsupportedOperationException( "unsupported T#K##V#Map implementation" ); } } --- 256,263 ---- public void putAll( T#K##V#Map map ) { ensureCapacity( map.size() ); ! T#K##V#Iterator iter = map.iterator(); ! while ( iter.hasNext() ) { ! iter.advance(); ! this.put( iter.key(), iter.value() ); } } *************** *** 321,324 **** --- 316,330 ---- /** + * removes the mapping at <tt>index</tt> from the map. + * + * @param index an <code>int</code> value + */ + public void removeAt( int index ) { + _values[index] = no_entry_value; + super.removeAt( index ); // clear key, state; adjust size + } + + + /** * Returns the keys of the map as a <tt>T#K#Set</tt> */ *************** *** 627,647 **** /** {@inheritDoc} */ public T#K#Iterator iterator() { ! return new T#K##V#KeyHashIterator( T#K##V#HashMap.this ) { ! protected #k# objectAtIndex( int index ) { ! return _set[index]; ! } ! }; ! } ! ! ! /** {@inheritDoc} */ ! public boolean removeElement( #k# key ) { ! return no_entry_value != T#K##V#HashMap.this.remove( key ); ! } ! ! ! /** {@inheritDoc} */ ! public boolean containsElement( #k# key ) { ! return T#K##V#HashMap.this.contains( key ); } --- 633,637 ---- /** {@inheritDoc} */ public T#K#Iterator iterator() { ! return new T#K##V#KeyHashIterator( T#K##V#HashMap.this ); } *************** *** 695,699 **** /** {@inheritDoc} */ public boolean remove( #k# entry ) { ! return no_entry_value == T#K##V#HashMap.this.remove( entry ); } --- 685,689 ---- /** {@inheritDoc} */ public boolean remove( #k# entry ) { ! return no_entry_value != T#K##V#HashMap.this.remove( entry ); } *************** *** 808,813 **** for ( int i = set.length; i-- > 0; ) { ! if ( states[i] == FULL && ( Arrays.binarySearch( array,set[i] ) < 0) ) { ! remove( set[i] ); changed = true; } --- 798,803 ---- for ( int i = set.length; i-- > 0; ) { ! if ( states[i] == FULL && ( Arrays.binarySearch( array, set[i] ) < 0) ) { ! removeAt( i ); changed = true; } *************** *** 834,837 **** --- 824,831 ---- /** {@inheritDoc} */ public boolean removeAll( T#K#Collection collection ) { + if ( this == collection ) { + clear(); + return true; + } boolean changed = false; T#K#Iterator iter = collection.iterator(); *************** *** 868,907 **** return T#K##V#HashMap.this.forEachKey( procedure ); } - } ! /** a view onto the values of the map. */ ! protected class TValueView implements T#V#Collection { ! ! /** {@inheritDoc} */ ! public T#V#Iterator iterator() { ! return new T#K##V#ValueHashIterator( T#K##V#HashMap.this ) { ! protected #v# objectAtIndex( int index ) { ! return _values[index]; } ! }; } ! /** {@inheritDoc} */ ! public boolean containsElement( #v# value ) { ! return T#K##V#HashMap.this.containsValue( value ); } ! /** {@inheritDoc} */ ! public boolean removeElement( #v# value ) { ! #v#[] values = _values; ! byte[] _state = T#K##V#HashMap.this._states; ! for ( int i = values.length; i-- > 0; ) { ! if ( ( _state[i] != FREE && _state[i] != REMOVED ) && ! value == values[i] ) { ! removeAt( i ); return true; } ! } ! return false; } --- 862,935 ---- return T#K##V#HashMap.this.forEachKey( procedure ); } ! @Override ! public boolean equals( Object other ) { ! if ( !( other instanceof T#K#Set ) ) { ! return false; ! } ! final T#K#Set that = ( T#K#Set ) other; ! if ( that.size() != this.size() ) { ! return false; ! } ! return forEach( new T#K#Procedure() { ! public final boolean execute( #k# key ) { ! return that.contains( key ); } ! } ); } ! @Override ! public int hashCode() { ! class HashProcedure implements T#K#Procedure { ! int hashcode = 0; ! ! public boolean execute( #k# key ) { ! hashcode += HashFunctions.hash( key ); ! return true; ! } ! ! public int getHashCode() { ! return hashcode; ! } ! } ! ! HashProcedure p = new HashProcedure(); ! forEachKey( p ); ! return p.getHashCode(); } ! @Override ! public String toString() { ! final StringBuilder buf = new StringBuilder( "{" ); ! forEachKey( new T#K#Procedure() { ! private boolean first = true; ! ! public boolean execute( #k# key ) { ! if ( first ) { ! first = false; ! } else { ! buf.append( "," ); ! } ! ! buf.append( key ); return true; } ! } ); ! buf.append( "}" ); ! return buf.toString(); ! } ! } ! ! /** a view onto the values of the map. */ ! protected class TValueView implements T#V#Collection { ! ! /** {@inheritDoc} */ ! public T#V#Iterator iterator() { ! return new T#K##V#ValueHashIterator( T#K##V#HashMap.this ); } *************** *** 1062,1066 **** for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL && ( Arrays.binarySearch( array, values[i] ) < 0) ) { ! remove( values[i] ); changed = true; } --- 1090,1094 ---- for ( int i = values.length; i-- > 0; ) { if ( states[i] == FULL && ( Arrays.binarySearch( array, values[i] ) < 0) ) { ! removeAt( i ); changed = true; } *************** *** 1087,1090 **** --- 1115,1122 ---- /** {@inheritDoc} */ public boolean removeAll( T#V#Collection collection ) { + if ( this == collection ) { + clear(); + return true; + } boolean changed = false; T#V#Iterator iter = collection.iterator(); *************** *** 1121,1124 **** --- 1153,1216 ---- return T#K##V#HashMap.this.forEachValue( procedure ); } + + + @Override + public boolean equals( Object other ) { + if ( !( other instanceof T#V#Set ) ) { + return false; + } + final T#V#Set that = ( T#V#Set ) other; + if ( that.size() != this.size() ) { + return false; + } + return forEach( new T#V#Procedure() { + public final boolean execute( #v# value ) { + return that.contains( value ); + } + } ); + } + + + @Override + public int hashCode() { + class HashProcedure implements T#V#Procedure { + int hashcode = 0; + + public boolean execute( #v# value ) { + hashcode += HashFunctions.hash( value ); + return true; + } + + public int getHashCode() { + return hashcode; + } + } + + HashProcedure p = new HashProcedure(); + forEachValue( p ); + return p.getHashCode(); + } + + + @Override + public String toString() { + final StringBuilder buf = new StringBuilder( "{" ); + forEachValue( new T#V#Procedure() { + private boolean first = true; + + public boolean execute( #v# value ) { + if ( first ) { + first = false; + } else { + buf.append( "," ); + } + + buf.append( value ); + return true; + } + } ); + buf.append( "}" ); + return buf.toString(); + } } *************** *** 1147,1150 **** --- 1239,1261 ---- return _set[_index]; } + + + /** @{inheritDoc} */ + public void remove() { + if ( _expectedSize != _hash.size() ) { + throw new ConcurrentModificationException(); + } + + // Disable auto compaction during the remove. This is a workaround for bug 1642768. + try { + _hash.tempDisableAutoCompaction(); + T#K##V#HashMap.this.removeAt( _index ); + } + finally { + _hash.reenableAutoCompaction( false ); + } + + _expectedSize--; + } } *************** *** 1176,1191 **** ! /** ! * Replace the value of the mapping at the iterator's position with the ! * specified value. Note that you must <tt>advance()</tt> the iterator at ! * least once before invoking this method. ! * ! * @param val the value to set in the current entry ! * @return the old value of the entry. ! */ ! public #v# set( #v# val ) { ! #v# old = _values[_index]; ! _values[_index] = val; ! return old; } } --- 1287,1306 ---- ! /** @{inheritDoc} */ ! public void remove() { ! if ( _expectedSize != _hash.size() ) { ! throw new ConcurrentModificationException(); ! } ! ! // Disable auto compaction during the remove. This is a workaround for bug 1642768. ! try { ! _hash.tempDisableAutoCompaction(); ! T#K##V#HashMap.this.removeAt( _index ); ! } ! finally { ! _hash.reenableAutoCompaction( false ); ! } ! ! _expectedSize--; } } *************** *** 1203,1206 **** --- 1318,1322 ---- } + /** * Moves the iterator forward to the next entry in the underlying map. *************** *** 1212,1215 **** --- 1328,1332 ---- } + /** * Provides access to the key of the mapping at the iterator's position. *************** *** 1223,1226 **** --- 1340,1344 ---- } + /** * Provides access to the value of the mapping at the iterator's position. *************** *** 1234,1237 **** --- 1352,1356 ---- } + /** * Replace the value of the mapping at the iterator's position with the *************** *** 1247,1250 **** --- 1366,1388 ---- return old; } + + + /** @{inheritDoc} */ + public void remove() { + if ( _expectedSize != _hash.size() ) { + throw new ConcurrentModificationException(); + } + + // Disable auto compaction during the remove. This is a workaround for bug 1642768. + try { + _hash.tempDisableAutoCompaction(); + T#K##V#HashMap.this.removeAt( _index ); + } + finally { + _hash.reenableAutoCompaction( false ); + } + + _expectedSize--; + } } *************** *** 1263,1271 **** @Override public boolean equals( Object other ) { ! if (! (other instanceof T#K##V#HashMap)) { return false; } T#K##V#HashMap that = ( T#K##V#HashMap ) other; ! if (that.size() != this.size()) { return false; } --- 1401,1409 ---- @Override public boolean equals( Object other ) { ! if (! ( other instanceof T#K##V#HashMap ) ) { return false; } T#K##V#HashMap that = ( T#K##V#HashMap ) other; ! if ( that.size() != this.size() ) { return false; } *************** *** 1292,1296 **** ! public final boolean execute( #k# key, #v# value ) { int index = _otherMap.index( key ); if ( index >= 0 && eq( value, _otherMap.get( key ) ) ) { --- 1430,1434 ---- ! public boolean execute( #k# key, #v# value ) { int index = _otherMap.index( key ); if ( index >= 0 && eq( value, _otherMap.get( key ) ) ) { |
From: Jeff R. <uph...@us...> - 2009-09-11 22:20:59
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/set/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22836/templates/gnu/trove/set/hash Modified Files: Tag: TROVE_3_WORKING _E_HashSet.template Log Message: Full test coverage for TPrimitivePrimitiveHashMaps, changes associated with test implemenation Index: _E_HashSet.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/set/hash/Attic/_E_HashSet.template,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** _E_HashSet.template 9 Sep 2009 01:15:54 -0000 1.1.2.3 --- _E_HashSet.template 11 Sep 2009 22:20:48 -0000 1.1.2.4 *************** *** 414,419 **** for ( int i = set.length; i-- > 0; ) { ! if ( states[i] == FULL && ( Arrays.binarySearch( array,set[i] ) < 0) ) { ! remove(set[i]); changed = true; } --- 414,419 ---- for ( int i = set.length; i-- > 0; ) { ! if ( states[i] == FULL && ( Arrays.binarySearch( array, set[i] ) < 0) ) { ! removeAt( i ); changed = true; } |
From: Jeff R. <uph...@us...> - 2009-09-11 22:20:57
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22836/test/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING TPrimitivePrimitiveHashMapTest.java Log Message: Full test coverage for TPrimitivePrimitiveHashMaps, changes associated with test implemenation Index: TPrimitivePrimitiveHashMapTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/map/hash/Attic/TPrimitivePrimitiveHashMapTest.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** TPrimitivePrimitiveHashMapTest.java 9 Sep 2009 01:15:54 -0000 1.1.2.2 --- TPrimitivePrimitiveHashMapTest.java 11 Sep 2009 22:20:48 -0000 1.1.2.3 *************** *** 28,33 **** --- 28,38 ---- import gnu.trove.iterator.TIntLongIterator; import gnu.trove.iterator.TIntIterator; + import gnu.trove.iterator.TLongIterator; import gnu.trove.map.TIntLongMap; + import gnu.trove.map.TIntIntMap; import gnu.trove.set.TIntSet; + import gnu.trove.set.TLongSet; + import gnu.trove.set.hash.TIntHashSet; + import gnu.trove.set.hash.TLongHashSet; [...1586 lines suppressed...] + // public TIntSet keySet() { return null; } + // public int[] keys() { return new int[0]; } + // public int[] keys( int[] array ) { return new int[0]; } + // public TLongCollection valueCollection() { return null; } + // public long[] values() { return new long[0]; } + // public long[] values( long[] array ) { return new long[0]; } + // public boolean containsValue( long val ) { return false; } + // public boolean containsKey( int key ) { return false; } + // public TIntLongIterator iterator() { return null; } + // public boolean forEachKey( TIntProcedure procedure ) { return false; } + // public boolean forEachValue( TLongProcedure procedure ) { return false; } + // public boolean forEachEntry( TIntLongProcedure procedure ) { return false; } + // public void transformValues( TLongFunction function ) { } + // public boolean retainEntries( TIntLongProcedure procedure ) { return false; } + // public boolean increment( int key ) { return false; } + // public boolean adjustValue( int key, long amount ) { return false; } + // public long adjustOrPutValue( int key, long adjust_amount, long put_amount ) { return 0; } + // public boolean isEmpty() { return true; } + // } } |
From: Jeff R. <uph...@us...> - 2009-09-11 22:19:36
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22517/test/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING TPrimitiveArrayListTest.java Log Message: Remove overlooked debugging line Index: TPrimitiveArrayListTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/list/array/Attic/TPrimitiveArrayListTest.java,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** TPrimitiveArrayListTest.java 11 Sep 2009 05:52:03 -0000 1.1.2.5 --- TPrimitiveArrayListTest.java 11 Sep 2009 22:19:25 -0000 1.1.2.6 *************** *** 1424,1428 **** TIntList built = foreach.getBuilt(); built.reverse(); - System.out.println( built ); assertEquals( 1, built.size() ); assertEquals( 19, built.get( 0 ) ); --- 1424,1427 ---- |
From: Jeff R. <uph...@us...> - 2009-09-11 22:16:52
|
Update of /cvsroot/trove4j/trove/src/gnu/trove/iterator/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21800/src/gnu/trove/iterator/hash Modified Files: Tag: TROVE_3_WORKING TPrimitiveIterator.java Log Message: Format in the new code style. Index: TPrimitiveIterator.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/iterator/hash/Attic/TPrimitiveIterator.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** TPrimitiveIterator.java 8 Sep 2009 16:26:40 -0000 1.1.2.2 --- TPrimitiveIterator.java 11 Sep 2009 22:16:37 -0000 1.1.2.3 *************** *** 53,58 **** /** the data structure this iterator traverses */ protected final TPrimitiveHash _hash; ! /** the number of elements this iterator believes are in the ! * data structure it accesses. */ protected int _expectedSize; /** the index used for iteration. */ --- 53,60 ---- /** the data structure this iterator traverses */ protected final TPrimitiveHash _hash; ! /** ! * the number of elements this iterator believes are in the ! * data structure it accesses. ! */ protected int _expectedSize; /** the index used for iteration. */ *************** *** 60,64 **** - /** * Creates a <tt>TPrimitiveIterator</tt> for the specified collection. --- 62,65 ---- *************** *** 106,109 **** --- 107,111 ---- } + /** * Removes the last entry returned by the iterator. *************** *** 129,132 **** --- 131,135 ---- } + /** * Sets the internal <tt>index</tt> so that the `next' object *************** *** 136,140 **** // doing the assignment && < 0 in one line shaves // 3 opcodes... ! if ((_index = nextIndex()) < 0) { throw new NoSuchElementException(); } --- 139,143 ---- // doing the assignment && < 0 in one line shaves // 3 opcodes... ! if ( ( _index = nextIndex() ) < 0 ) { throw new NoSuchElementException(); } *************** *** 142,145 **** - } // TPrimitiveIterator --- 145,147 ---- |
From: Jeff R. <uph...@us...> - 2009-09-11 05:53:49
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/map/hash In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22295/test/gnu/trove/map/hash Modified Files: Tag: TROVE_3_WORKING THashMapTest.java Log Message: Remove obsolete test, suppress warnings. Index: THashMapTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/map/hash/Attic/THashMapTest.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** THashMapTest.java 9 Sep 2009 06:24:06 -0000 1.1.2.2 --- THashMapTest.java 11 Sep 2009 05:53:37 -0000 1.1.2.3 *************** *** 514,537 **** - // TODO: implement or move when primitive maps are implemented. - // public void testSerializablePrimitives() throws Exception { - // TIntIntHashMap mm = new TIntIntHashMap(); - // mm.put( 1, -1 ); - // mm.put( 0, 0 ); - // mm.put( 127, 68888 ); - // - // ByteArrayOutputStream baos = new ByteArrayOutputStream(); - // ObjectOutputStream oos = new ObjectOutputStream( baos ); - // oos.writeObject( mm ); - // - // ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() ); - // ObjectInputStream ois = new ObjectInputStream( bais ); - // - // TIntIntHashMap mm2 = (TIntIntHashMap) ois.readObject(); - // - // assertEquals( mm, mm2 ); - // } - - public void testRetainEntries() throws Exception { ss_map.put( "a", "b" ); --- 514,517 ---- *************** *** 573,576 **** --- 553,557 ---- + @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) public void testBadlyWrittenKey() { THashMap<THashSetTest.Crap, Integer> map = new THashMap<THashSetTest.Crap, Integer>(); *************** *** 639,642 **** --- 620,624 ---- + @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) public void testMapEntrySetHashCode() { ss_map.put( "one", "foo" ); *************** *** 698,702 **** * once, I figure I'll leave it in. - RDE */ ! @SuppressWarnings({"ForLoopReplaceableByForEach"}) public void testProblematicRemove() { int[] to_add = new int[]{ --- 680,685 ---- * once, I figure I'll leave it in. - RDE */ ! @SuppressWarnings({"ForLoopReplaceableByForEach", ! "MismatchedQueryAndUpdateOfCollection"}) public void testProblematicRemove() { int[] to_add = new int[]{ *************** *** 938,941 **** --- 921,925 ---- + @SuppressWarnings({"ToArrayCallWithZeroLengthArrayArgument"}) public void testValuesToArray() { int element_count = 10; |
From: Jeff R. <uph...@us...> - 2009-09-11 05:52:14
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22141/test/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING TPrimitiveArrayListTest.java Log Message: Full testing of TPrimitiveArrayLists Index: TPrimitiveArrayListTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/list/array/Attic/TPrimitiveArrayListTest.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** TPrimitiveArrayListTest.java 11 Sep 2009 04:48:26 -0000 1.1.2.4 --- TPrimitiveArrayListTest.java 11 Sep 2009 05:52:03 -0000 1.1.2.5 *************** *** 16,19 **** --- 16,21 ---- import gnu.trove.set.TIntSet; import gnu.trove.set.hash.TIntHashSet; + import gnu.trove.TIntCollection; + *************** *** 565,574 **** } ! assertTrue( "list: " + list + " should contain all of array: " + ints, ! list.containsAll( ints ) ); ints[5] = 1138; ! assertFalse( "list: " + list + " should cnot ontain all of array: " + ints, ! list.containsAll( ints ) ); } --- 567,576 ---- } ! assertTrue( "list: " + list + " should contain all of array: " + ! Arrays.toString( ints ), list.containsAll( ints ) ); ints[5] = 1138; ! assertFalse( "list: " + list + " should cnot ontain all of array: " + ! Arrays.toString( ints ), list.containsAll( ints ) ); } *************** *** 700,704 **** TIntList other = new TIntArrayList(); for ( int i = 0; i < element_count; i++ ) { ! other.add( Integer.valueOf( i ) ); } --- 702,706 ---- TIntList other = new TIntArrayList(); for ( int i = 0; i < element_count; i++ ) { ! other.add( i ); } *************** *** 822,826 **** TIntList other = new TIntArrayList(); for ( int i = 0; i < element_count; i++ ) { ! other.add( Integer.valueOf( i ) ); } --- 824,828 ---- TIntList other = new TIntArrayList(); for ( int i = 0; i < element_count; i++ ) { ! other.add( i ); } *************** *** 833,853 **** assertEquals( element_count, other.size() ); ! assertFalse( list.removeAll( list ) ); ! assertFalse( list.retainAll( other ) ); ! assertEquals( element_count, list.size() ); for ( int i = 0; i < list.size(); i++ ) { assertEquals( i , list.get( i ) ); } other.remove( 0 ); other.remove( 5 ); other.remove( 10 ); other.remove( 15 ); ! assertTrue( list.retainAll( other ) ); ! int expected = element_count - 4; assertEquals( expected, list.size() ); for ( int i = 0; i < list.size(); i++ ) { ! expected = ( int ) Math.floor( i / 4 ) + i + 1; assertEquals( "expected: " + expected + ", was: " + list.get( i ) + ", list: " + list, expected , list.get( i ) ); --- 835,914 ---- assertEquals( element_count, other.size() ); ! assertTrue( list.removeAll( list ) ); ! assertEquals( 0, list.size() ); ! assertTrue( list.isEmpty() ); ! // Reset the list ! list = new TIntArrayList( 20 ); ! for ( int i = 0; i < element_count; i++ ) { ! list.add( i ); ! } ! ! assertTrue( list.removeAll( other ) ); ! assertEquals( 0, list.size() ); ! assertTrue( list.isEmpty() ); for ( int i = 0; i < list.size(); i++ ) { assertEquals( i , list.get( i ) ); } + // Reset the list + list = new TIntArrayList( 20 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + other.remove( 0 ); other.remove( 5 ); other.remove( 10 ); other.remove( 15 ); ! assertTrue( list.removeAll( other ) ); ! int expected = 4; ! assertEquals( "expected: " + expected + ", was: " + list.size() + ", list: " + list , ! expected, list.size() ); ! for ( int i = 0; i < list.size(); i++ ) { ! expected = i * 5; ! assertEquals( "expected: " + expected + ", was: " + list.get( i ) + ", list: " + list, ! expected , list.get( i ) ); ! } ! } ! ! ! public void testRemoveAllArray() { ! int element_count = 20; ! int ints[] = new int[element_count]; ! for ( int i = 0; i < element_count; i++ ) { ! ints[i] = i; ! } ! ! TIntList list = new TIntArrayList( 20 ); ! for ( int i = 0; i < element_count; i++ ) { ! list.add( i ); ! } ! ! assertEquals( element_count, list.size() ); ! ! assertTrue( list.removeAll( ints ) ); ! assertEquals( 0, list.size() ); ! assertTrue( list.isEmpty() ); ! ! // Reset the list ! list = new TIntArrayList( 20 ); ! for ( int i = 0; i < element_count; i++ ) { ! list.add( i ); ! } ! ! ints = new int[( element_count - 4 )] ; ! for ( int i = 0, j = 0; i < ints.length; i++, j++ ) { ! if ( i % 4 == 0 ) { ! j++; ! } ! ints[i] = j; ! } ! ! assertTrue( list.removeAll( ints ) ); ! int expected = 4; assertEquals( expected, list.size() ); for ( int i = 0; i < list.size(); i++ ) { ! expected = i * 5; assertEquals( "expected: " + expected + ", was: " + list.get( i ) + ", list: " + list, expected , list.get( i ) ); *************** *** 856,865 **** ! public void testIterator() { TIntIterator iter = list.iterator(); assertTrue( "iter should have next: " + list.size(), iter.hasNext() ); } --- 917,1017 ---- ! public void testShuffle() { ! int element_count = 20; ! TIntList list = new TIntArrayList( 20 ); ! for ( int i = 0; i < element_count; i++ ) { ! list.add( i ); ! } ! ! list.shuffle( new Random( System.currentTimeMillis() ) ); ! for ( int i = 0; i < list.size(); i++ ) { ! assertTrue( list.contains( i ) ); ! } ! } public void testIterator() { + int element_count = 20; + TIntList list = new TIntArrayList(); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + TIntIterator iter = list.iterator(); assertTrue( "iter should have next: " + list.size(), iter.hasNext() ); + + int j = 0; + while ( iter.hasNext() ) { + int next = iter.next(); + assertEquals( j, next ); + j++; + } + assertFalse( iter.hasNext() ); + + iter = list.iterator(); + for ( int i = 0; i < element_count / 2; i++ ) { + iter.next(); + } + iter.remove(); + try { + // trying to remove it again should fail. + iter.remove(); + fail( "Expected IllegalStateException" ); + } + catch ( IllegalStateException ex ) { + // Expected + } + for ( int i = 0; i < element_count / 2 - 1; i++ ) { + iter.next(); + } + } + + + public void testIteratorAbuseNext() { + int element_count = 20; + TIntList list = new TIntArrayList(); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + TIntIterator iter = list.iterator(); + while ( iter.hasNext() ) { + iter.next(); + } + assertFalse( iter.hasNext() ); + + list.remove( 5, 10 ); + assertFalse( iter.hasNext() ); + try { + iter.next(); + fail( "Expected NoSuchElementException" ); + } catch( NoSuchElementException ex ) { + // Expected. + } + } + + + public void testIteratorAbuseRemove() { + int element_count = 20; + TIntList list = new TIntArrayList(); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + TIntIterator iter = list.iterator(); + while ( iter.hasNext() ) { + iter.next(); + } + assertFalse( iter.hasNext() ); + + list.remove( 5, 10 ); + assertFalse( iter.hasNext() ); + + try { + iter.remove(); + fail( "Expected ConcurrentModificationException" ); + } catch( ConcurrentModificationException ex ) { + // Expected. + } } *************** *** 1189,1192 **** --- 1341,1373 ---- + public void testForEachFalse() { + int element_count = 20; + TIntList a = new TIntArrayList(); + for ( int i = 1; i < element_count; i++ ) { + a.add( i ); + } + + class ForEach implements TIntProcedure { + TIntList built = new TIntArrayList(); + + + public boolean execute( int value ) { + built.add( value ); + return false; + } + + TIntList getBuilt() { + return built; + } + } + + ForEach foreach = new ForEach(); + a.forEach( foreach ); + TIntList built = foreach.getBuilt(); + assertEquals( 1, built.size() ); + assertEquals( 1, built.get( 0 ) ); + } + + public void testForEachDescending() { int element_count = 20; *************** *** 1218,1221 **** --- 1399,1433 ---- + public void testForEachDescendingFalse() { + int element_count = 20; + TIntList a = new TIntArrayList(); + for ( int i = 1; i < element_count; i++ ) { + a.add( i ); + } + + class ForEach implements TIntProcedure { + TIntList built = new TIntArrayList(); + + + public boolean execute( int value ) { + built.add( value ); + return false; + } + + TIntList getBuilt() { + return built; + } + } + + ForEach foreach = new ForEach(); + a.forEachDescending( foreach ); + TIntList built = foreach.getBuilt(); + built.reverse(); + System.out.println( built ); + assertEquals( 1, built.size() ); + assertEquals( 19, built.get( 0 ) ); + } + + public void testTransform() { int element_count = 20; *************** *** 1307,1317 **** public void testEquals() { int element_count = 20; ! TIntList a = new TIntArrayList(); for ( int i = 1; i <= element_count; i++ ) { ! a.add( i ); } ! assertEquals( a, a ); ! assertEquals( a, new TIntArrayList( a ) ); } --- 1519,1544 ---- public void testEquals() { int element_count = 20; ! TIntList list = new TIntArrayList(); for ( int i = 1; i <= element_count; i++ ) { ! list.add( i ); } ! assertEquals( list, list ); ! assertEquals( list, new TIntArrayList( list ) ); ! ! ! TIntCollection collection = new TIntHashSet(); ! for ( int i = 1; i <= element_count; i++ ) { ! collection.add( i ); ! } ! ! assertFalse( list.equals( collection ) ); ! ! collection.add( 1138 ); ! assertFalse( list.equals( collection ) ); ! ! TIntList other = new TIntArrayList( list ); ! other.replace( 10, 1138 ); ! assertFalse( list.equals( other ) ); } |
From: Jeff R. <uph...@us...> - 2009-09-11 05:52:13
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22141/templates/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING _E_ArrayList.template Log Message: Full testing of TPrimitiveArrayLists Index: _E_ArrayList.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/list/array/Attic/_E_ArrayList.template,v retrieving revision 1.1.2.14 retrieving revision 1.1.2.15 diff -C2 -d -r1.1.2.14 -r1.1.2.15 *** _E_ArrayList.template 11 Sep 2009 04:48:26 -0000 1.1.2.14 --- _E_ArrayList.template 11 Sep 2009 05:52:04 -0000 1.1.2.15 *************** *** 584,589 **** public boolean addAll( #e#[] array ) { boolean changed = false; ! for ( int i = 0; i < array.length; i++ ) { ! if ( add( array[i] ) ) { changed = true; } --- 584,589 ---- public boolean addAll( #e#[] array ) { boolean changed = false; ! for ( #e# element : array ) { ! if ( add( element ) ) { changed = true; } *************** *** 594,597 **** --- 594,598 ---- /** {@inheritDoc} */ + @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll( Collection<?> collection ) { boolean modified = false; *************** *** 657,660 **** --- 658,665 ---- /** {@inheritDoc} */ public boolean removeAll( T#E#Collection collection ) { + if ( collection == this ) { + clear(); + return true; + } boolean changed = false; T#E#Iterator iter = collection.iterator(); *************** *** 1231,1235 **** /** {@inheritDoc} */ public boolean hasNext() { ! return cursor != size(); } --- 1236,1240 ---- /** {@inheritDoc} */ public boolean hasNext() { ! return cursor < size(); } |
From: Jeff R. <uph...@us...> - 2009-09-11 04:48:38
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/list In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17871/templates/gnu/trove/list Modified Files: Tag: TROVE_3_WORKING _E_List.template Log Message: Additional TPrimitiveList tests and fixes for bugs discovered by new tests. Index: _E_List.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/list/Attic/_E_List.template,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** _E_List.template 9 Sep 2009 01:15:54 -0000 1.1.2.3 --- _E_List.template 11 Sep 2009 04:48:26 -0000 1.1.2.4 *************** *** 201,205 **** * Removes <tt>value</tt> at a given offset from the list. * ! * @param entry an <code>#e#</code> value * @return an <tt>#e#</tt> that is the value removed. */ --- 201,206 ---- * Removes <tt>value</tt> at a given offset from the list. * ! * @param offset an <code>int</code> value that represents ! * the offset to the element to be removed * @return an <tt>#e#</tt> that is the value removed. */ |
From: Jeff R. <uph...@us...> - 2009-09-11 04:48:37
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17871/templates/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING _E_ArrayList.template Log Message: Additional TPrimitiveList tests and fixes for bugs discovered by new tests. Index: _E_ArrayList.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/list/array/Attic/_E_ArrayList.template,v retrieving revision 1.1.2.13 retrieving revision 1.1.2.14 diff -C2 -d -r1.1.2.13 -r1.1.2.14 *** _E_ArrayList.template 9 Sep 2009 07:01:39 -0000 1.1.2.13 --- _E_ArrayList.template 11 Sep 2009 04:48:26 -0000 1.1.2.14 *************** *** 529,532 **** --- 529,535 ---- /** {@inheritDoc} */ public boolean containsAll( T#E#Collection collection ) { + if ( this == collection ) { + return true; + } T#E#Iterator iter = collection.iterator(); while ( iter.hasNext() ) { *************** *** 581,585 **** public boolean addAll( #e#[] array ) { boolean changed = false; ! for ( int i = array.length; i-- > 0; ) { if ( add( array[i] ) ) { changed = true; --- 584,588 ---- public boolean addAll( #e#[] array ) { boolean changed = false; ! for ( int i = 0; i < array.length; i++ ) { if ( add( array[i] ) ) { changed = true; |
From: Jeff R. <uph...@us...> - 2009-09-11 04:48:37
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17871/test/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING TPrimitiveArrayListTest.java Log Message: Additional TPrimitiveList tests and fixes for bugs discovered by new tests. Index: TPrimitiveArrayListTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/list/array/Attic/TPrimitiveArrayListTest.java,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** TPrimitiveArrayListTest.java 9 Sep 2009 07:01:39 -0000 1.1.2.3 --- TPrimitiveArrayListTest.java 11 Sep 2009 04:48:26 -0000 1.1.2.4 *************** *** 3,7 **** import junit.framework.TestCase; ! import java.util.Arrays; import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; --- 3,7 ---- import junit.framework.TestCase; ! import java.util.*; import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; *************** *** 14,18 **** import gnu.trove.function.TIntFunction; import gnu.trove.iterator.TIntIterator; ! --- 14,19 ---- import gnu.trove.function.TIntFunction; import gnu.trove.iterator.TIntIterator; ! import gnu.trove.set.TIntSet; ! import gnu.trove.set.hash.TIntHashSet; *************** *** 354,366 **** } ! a.remove( 5 ); for ( int i = 0; i < 4; i++ ) { int expected = i + 1; assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); } ! for ( int i = 5; i < a.size(); i++ ) { int expected = i + 2; assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); } } --- 355,417 ---- } ! assertEquals( 6, a.get( 5 ) ); ! assertTrue( a.remove( 5 ) ); for ( int i = 0; i < 4; i++ ) { int expected = i + 1; assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); } ! for ( int i = 4; i < a.size(); i++ ) { ! int expected = i + 2; ! assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); ! } ! ! // Can't remove again from THIS list because it's not present. ! assertFalse( a.remove( 5 ) ); ! ! assertEquals( 6, a.removeAt( 4 ) ); ! for ( int i = 0; i < 4; i++ ) { ! int expected = i + 1; ! assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); ! } ! for ( int i = 4; i < a.size(); i++ ) { ! int expected = i + 3; ! assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); ! } ! a.insert( 4, 6 ); ! ! // Add a value twice, can remove it twice ! assertTrue( a.add( 5 ) ); ! assertTrue( a.add( 5 ) ); ! ! assertTrue( a.remove( 5 ) ); ! assertTrue( a.remove( 5 ) ); ! assertFalse( a.remove( 5 ) ); ! ! a.insert( 4, 5 ); ! assertTrue( a.add( 5 ) ); ! for ( int i = 0; i < 5; i++ ) { ! int expected = i + 1; ! assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); ! } ! for ( int i = 5; i < a.size() - 1; i++ ) { ! int expected = i + 1; ! assertTrue( "index " + i + " expected " + expected + ", list: " + a, ! a.get( i ) == expected ); ! } ! assertEquals( 5, a.get( a.size() - 1 ) ); ! ! assertTrue( a.remove( 5 ) ); ! assertEquals( element_count, a.size() ); ! for ( int i = 0; i < 4; i++ ) { ! int expected = i + 1; ! assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); ! } ! for ( int i = 4; i < a.size() - 1; i++ ) { int expected = i + 2; assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); } + assertEquals( 5, a.get( a.size() - 1 ) ); + + } *************** *** 402,406 **** a.remove( 5, 10 ); ! for ( int i = 0; i < 4; i++ ) { int expected = i + 1; assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); --- 453,457 ---- a.remove( 5, 10 ); ! for ( int i = 0; i < 5; i++ ) { int expected = i + 1; assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected ); *************** *** 430,433 **** --- 481,862 ---- + public void testContainsAllCollection() { + int element_count = 20; + SortedSet<Integer> set = new TreeSet<Integer>(); + for ( int i = 0; i < element_count; i++ ) { + set.add( Integer.valueOf( i ) ); + } + + TIntArrayList list = new TIntArrayList( 20 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + assertTrue( "list: " + list + " should contain all of set: " + set, + list.containsAll( set ) ); + + set.remove( element_count ); + assertTrue( "list: " + list + " should contain all of set: " + set, + list.containsAll( set ) ); + + list.remove( 5 ); + assertFalse( "list: " + list + " should not contain all of set: " + set, + list.containsAll( set ) ); + list.add( 5 ); + + // Test when not all objects are Integers.. + Set<Number> obj_set = new HashSet<Number>(); + for ( int i = 0; i < element_count; i++ ) { + if ( i != 5 ) { + obj_set.add( Integer.valueOf( i ) ); + } else { + obj_set.add( Long.valueOf( ( long ) i ) ); + } + } + assertFalse( "list should not contain all of obj_set", + list.containsAll( obj_set ) ); + } + + + public void testContainsAllTCollection() { + int element_count = 20; + TIntArrayList list = new TIntArrayList( element_count * 2 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + TIntArrayList other = new TIntArrayList( list ); + assertEquals( element_count, list.size() ); + assertEquals( element_count, other.size() ); + assertEquals( list, other ); + + assertTrue( "list should contain all of itself: " + list, list.containsAll( list ) ); + assertTrue( "list should contain all of equal list " + list + ", " + other, + list.containsAll( other ) ); + for ( int i = 0; i < other.size(); i++ ) { + if ( i % 2 == 0 ) { + other.removeAt( i ); + } + } + assertTrue( "list: " + list + " should contain all of other: " + other, + list.containsAll( other ) ); + + other.add( 1138 ); + assertFalse( "list: " + list + " should not contain all of other: " + other, + list.containsAll( other ) ); + + TIntSet set = new TIntHashSet( list ); + assertTrue( "list: " + list + " should contain all of set: " + set, + list.containsAll( set ) ); + + set.add ( 1138 ); + assertFalse( "list: " + list + " should not contain all of set: " + set, + list.containsAll( set ) ); + } + + + public void testContainsAllArray() { + int element_count = 20; + int[] ints = new int[element_count]; + TIntArrayList list = new TIntArrayList( element_count * 2 ); + for ( int i = 0; i < element_count; i++ ) { + ints[i] = i; + list.add( i ); + } + + assertTrue( "list: " + list + " should contain all of array: " + ints, + list.containsAll( ints ) ); + + ints[5] = 1138; + assertFalse( "list: " + list + " should cnot ontain all of array: " + ints, + list.containsAll( ints ) ); + } + + + public void testAddAllCollection() { + int element_count = 20; + SortedSet<Integer> set = new TreeSet<Integer>(); + for ( int i = 0; i < element_count; i++ ) { + set.add( Integer.valueOf( i ) ); + } + + TIntArrayList list = new TIntArrayList( 20 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + assertEquals( element_count, set.size() ); + assertEquals( element_count, list.size() ); + + list.addAll( set ); + assertEquals( element_count * 2, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + int expected; + if ( i < element_count ) { + expected = i; + } else { + expected = i - element_count; + } + assertEquals( expected , list.get( i ) ); + } + } + + + public void testAddAllTCollection() { + int element_count = 20; + TIntArrayList source = new TIntArrayList(); + for ( int i = 0; i < element_count; i++ ) { + source.add( Integer.valueOf( i ) ); + } + + TIntArrayList list = new TIntArrayList( 20 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + assertEquals( element_count, source.size() ); + assertEquals( element_count, list.size() ); + + list.addAll( source ); + assertEquals( element_count * 2, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + int expected; + if ( i < element_count ) { + expected = i; + } else { + expected = i - element_count; + } + assertEquals( expected , list.get( i ) ); + } + } + + + public void testAddAllArray() { + int element_count = 20; + int[] ints = new int[element_count]; + TIntArrayList list = new TIntArrayList(); + for ( int i = 0; i < element_count; i++ ) { + ints[i] = i; + list.add( Integer.valueOf( i ) ); + } + + assertEquals( element_count, list.size() ); + + assertTrue ( list.addAll( ints ) ); + assertEquals( element_count * 2, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + int expected; + if ( i < element_count ) { + expected = i; + } else { + expected = i - element_count; + } + assertEquals( "expected: " + expected + ", got: " + list.get( i ) + + ", list: " + list + ", array: " + Arrays.toString( ints ), + expected , list.get( i ) ); + } + } + + + public void testRetainAllCollection() { + int element_count = 20; + SortedSet<Integer> set = new TreeSet<Integer>(); + for ( int i = 0; i < element_count; i++ ) { + set.add( Integer.valueOf( i ) ); + } + + TIntList list = new TIntArrayList( 20 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + assertEquals( element_count, set.size() ); + assertEquals( element_count, list.size() ); + + assertFalse( list.retainAll( set ) ); + assertEquals( element_count, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + assertEquals( i , list.get( i ) ); + } + + set.remove( 0 ); + set.remove( 5 ); + set.remove( 10 ); + set.remove( 15 ); + assertTrue( list.retainAll( set ) ); + int expected = element_count - 4; + assertEquals( "expected: " + expected + ", was: " + list.size() + ", list: " + list , + expected, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + expected = ( int ) Math.floor( i / 4 ) + i + 1; + assertEquals( "expected: " + expected + ", was: " + list.get( i ) + ", list: " + list, + expected , list.get( i ) ); + } + } + + + public void testRetainAllTCollection() { + int element_count = 20; + TIntList other = new TIntArrayList(); + for ( int i = 0; i < element_count; i++ ) { + other.add( Integer.valueOf( i ) ); + } + + TIntList list = new TIntArrayList( 20 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + assertEquals( element_count, list.size() ); + assertEquals( element_count, other.size() ); + + assertFalse( list.retainAll( list ) ); + + assertFalse( list.retainAll( other ) ); + assertEquals( element_count, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + assertEquals( i , list.get( i ) ); + } + + other.remove( 0 ); + other.remove( 5 ); + other.remove( 10 ); + other.remove( 15 ); + assertTrue( list.retainAll( other ) ); + int expected = element_count - 4; + assertEquals( expected, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + expected = ( int ) Math.floor( i / 4 ) + i + 1; + assertEquals( "expected: " + expected + ", was: " + list.get( i ) + ", list: " + list, + expected , list.get( i ) ); + } + } + + + public void testRetainAllArray() { + int element_count = 20; + int ints[] = new int[element_count]; + for ( int i = 0; i < element_count; i++ ) { + ints[i] = i; + } + + TIntList list = new TIntArrayList( 20 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + assertEquals( element_count, list.size() ); + + assertFalse( list.retainAll( ints ) ); + assertEquals( element_count, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + assertEquals( i , list.get( i ) ); + } + + ints = new int[( element_count - 4 )] ; + for ( int i = 0, j = 0; i < ints.length; i++, j++ ) { + if ( i % 4 == 0 ) { + j++; + } + ints[i] = j; + } + assertTrue( list.retainAll( ints ) ); + int expected = element_count - 4; + assertEquals( expected, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + expected = ( int ) Math.floor( i / 4 ) + i + 1; + assertEquals( "expected: " + expected + ", was: " + list.get( i ) + ", list: " + list, + expected , list.get( i ) ); + } + } + + + public void testRemoveAllCollection() { + int element_count = 20; + SortedSet<Integer> set = new TreeSet<Integer>(); + for ( int i = 0; i < element_count; i++ ) { + set.add( Integer.valueOf( i ) ); + } + + TIntList list = new TIntArrayList( 20 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + assertEquals( element_count, set.size() ); + assertEquals( element_count, list.size() ); + + assertTrue( list.removeAll( set ) ); + assertTrue( list.isEmpty() ); + assertEquals( 0, list.size() ); + assertEquals( element_count, set.size() ); + for ( int i = 0; i < set.size(); i++ ) { + assertTrue( set.contains( Integer.valueOf( i ) ) ); + } + + + // Reset the list + list = new TIntArrayList( 20 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + set.remove( 0 ); + set.remove( 5 ); + set.remove( 10 ); + set.remove( 15 ); + assertTrue( list.removeAll( set ) ); + int expected = 4; + assertEquals( "expected: " + expected + ", was: " + list.size() + ", list: " + list , + expected, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + expected = i * 5; + assertEquals( "expected: " + expected + ", was: " + list.get( i ) + ", list: " + list, + expected , list.get( i ) ); + } + } + + + public void testRemoveAllTCollection() { + int element_count = 20; + TIntList other = new TIntArrayList(); + for ( int i = 0; i < element_count; i++ ) { + other.add( Integer.valueOf( i ) ); + } + + TIntList list = new TIntArrayList( 20 ); + for ( int i = 0; i < element_count; i++ ) { + list.add( i ); + } + + assertEquals( element_count, list.size() ); + assertEquals( element_count, other.size() ); + + assertFalse( list.removeAll( list ) ); + + assertFalse( list.retainAll( other ) ); + assertEquals( element_count, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + assertEquals( i , list.get( i ) ); + } + + other.remove( 0 ); + other.remove( 5 ); + other.remove( 10 ); + other.remove( 15 ); + assertTrue( list.retainAll( other ) ); + int expected = element_count - 4; + assertEquals( expected, list.size() ); + for ( int i = 0; i < list.size(); i++ ) { + expected = ( int ) Math.floor( i / 4 ) + i + 1; + assertEquals( "expected: " + expected + ", was: " + list.get( i ) + ", list: " + list, + expected , list.get( i ) ); + } + } + + + + + public void testIterator() { TIntIterator iter = list.iterator(); |
From: Jeff R. <uph...@us...> - 2009-09-09 07:01:52
|
Update of /cvsroot/trove4j/trove/test/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13971/test/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING TPrimitiveArrayListTest.java Log Message: Fix TPrimitiveArrayIterators Index: TPrimitiveArrayListTest.java =================================================================== RCS file: /cvsroot/trove4j/trove/test/gnu/trove/list/array/Attic/TPrimitiveArrayListTest.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** TPrimitiveArrayListTest.java 9 Sep 2009 01:15:54 -0000 1.1.2.2 --- TPrimitiveArrayListTest.java 9 Sep 2009 07:01:39 -0000 1.1.2.3 *************** *** 13,16 **** --- 13,17 ---- import gnu.trove.procedure.TIntProcedure; import gnu.trove.function.TIntFunction; + import gnu.trove.iterator.TIntIterator; *************** *** 429,432 **** --- 430,439 ---- + public void testIterator() { + TIntIterator iter = list.iterator(); + assertTrue( "iter should have next: " + list.size(), iter.hasNext() ); + } + + public void testEnsureCapacity() { int size = 1000; |
From: Jeff R. <uph...@us...> - 2009-09-09 07:01:50
|
Update of /cvsroot/trove4j/trove/templates/gnu/trove/list/array In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13971/templates/gnu/trove/list/array Modified Files: Tag: TROVE_3_WORKING _E_ArrayList.template Log Message: Fix TPrimitiveArrayIterators Index: _E_ArrayList.template =================================================================== RCS file: /cvsroot/trove4j/trove/templates/gnu/trove/list/array/Attic/_E_ArrayList.template,v retrieving revision 1.1.2.12 retrieving revision 1.1.2.13 diff -C2 -d -r1.1.2.12 -r1.1.2.13 *** _E_ArrayList.template 9 Sep 2009 06:24:51 -0000 1.1.2.12 --- _E_ArrayList.template 9 Sep 2009 07:01:39 -0000 1.1.2.13 *************** *** 32,38 **** import java.io.ObjectInput; import java.io.ObjectOutput; ! import java.util.Arrays; ! import java.util.Collection; ! import java.util.Random; --- 32,36 ---- import java.io.ObjectInput; import java.io.ObjectOutput; ! import java.util.*; *************** *** 97,114 **** /** ! * Creates a new <code>T#E#ArrayList</code> instance that is ! * a copy of the instanced passed to us. * ! * @param list the instance to copy */ ! public T#E#ArrayList ( T#E#List list ) { ! if ( list instanceof T#E#ArrayList ) { ! T#E#ArrayList array_list = ( T#E#ArrayList ) list; ! this._data = array_list.toArray(); ! this._pos = array_list._pos; ! this.no_entry_value = array_list.no_entry_value; ! } else { ! throw new UnsupportedOperationException( "only supports T#E#ArrayList" ); ! } } --- 95,106 ---- /** ! * Creates a new <code>T#E#ArrayList</code> instance that contains ! * a copy of the collection passed to us. * ! * @param collection the collection to copy */ ! public T#E#ArrayList ( T#E#Collection collection ) { ! this( collection.size() ); ! addAll( collection ); } *************** *** 514,518 **** /** {@inheritDoc} */ public T#E#Iterator iterator() { ! return new T#E#ArrayIterator(); } --- 506,510 ---- /** {@inheritDoc} */ public T#E#Iterator iterator() { ! return new T#E#ArrayIterator( 0 ); } *************** *** 1218,1227 **** class T#E#ArrayIterator implements T#E#Iterator { ! /** The array of data to be iterated over. */ ! private int index; ! T#E#ArrayIterator() { ! index = 0; } --- 1210,1226 ---- class T#E#ArrayIterator implements T#E#Iterator { ! /** Index of element to be returned by subsequent call to next. */ ! private int cursor = 0; ! ! /** ! * Index of element returned by most recent call to next or ! * previous. Reset to -1 if this element is deleted by a call ! * to remove. ! */ ! int lastRet = -1; ! T#E#ArrayIterator( int index ) { ! cursor = index; } *************** *** 1229,1246 **** /** {@inheritDoc} */ public boolean hasNext() { ! return ! ( index < _pos); ! } /** {@inheritDoc} */ ! public void remove() { ! T#E#ArrayList.this.remove( index, 1 ); } /** {@inheritDoc} */ ! public #e# next() { ! index++; ! return _data[index]; } } --- 1228,1260 ---- /** {@inheritDoc} */ public boolean hasNext() { ! return cursor != size(); ! } /** {@inheritDoc} */ ! public #e# next() { ! try { ! #e# next = get( cursor ); ! lastRet = cursor++; ! return next; ! } catch ( IndexOutOfBoundsException e ) { ! throw new NoSuchElementException(); ! } } /** {@inheritDoc} */ ! public void remove() { ! if ( lastRet == -1 ) ! throw new IllegalStateException(); ! ! try { ! T#E#ArrayList.this.remove( lastRet, 1); ! if ( lastRet < cursor ) ! cursor--; ! lastRet = -1; ! } catch ( IndexOutOfBoundsException e ) { ! throw new ConcurrentModificationException(); ! } } } |