All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jodd.util.collection.PrimitiveArrayLists.py Maven / Gradle / Ivy

There is a newer version: 3.4.1
Show newest version
# Create various primitive array lists

import string
import sys

types = ['int', 'long', 'float', 'double', 'char', 'byte', 'short', 'boolean']
for atype in types:

	# read file
	f = open('PrimitiveArrayList.java.template', 'r')
	template = f.read()
	f.close()

	# transform
	fp1 = ''
	fp2 = 'if (array[i] == data) {'
	if (atype == 'float') or (atype == 'double'):
		fp1 = ',  delta'
		fp2 = 'if (Math.abs(array[i] - data) <= delta) {'
	template = template.replace('', fp1)
	template = template.replace('', fp2)

	template = template.replace('', atype.title())
	template = template.replace('', atype)

	# write file
	dest = atype.title() + 'ArrayList.java'
	d = open(dest, 'w')
	d.write(template)
	d.close()




© 2015 - 2024 Weber Informatics LLC | Privacy Policy