Class Perm

java.lang.Object
   |
   +----java.util.Vector
           |
           +----Perm

class Perm
extends Vector
Class Perm maps a set of ints to a java.util.Vector of Integer objects. No doubt this is slower than using arrays. But I consistently get 900+ permutations per second using a P100 CPU, OS/2 with JIT, & Java 1.1.6 release. Use this code to give your own JVM/Java release a real test with this real-world benchmarking code!
NOTE to students who would use this code to get quickly through an assignment in your algorithms class: you've got so much editing ahead of you, that you might as well figure it out for yourself. ;-)
NOTE to IT professors: don't worry, this can't be any threat because I haven't taken your class, I don't own an algorithms book, and I'm only a hobbyist. If my posting this is a problem (which I would doubt on several counts), please feel free to write. ;-)

Author:
Tony Dahlman Nov 1998

Variable Index

 o eighty
Spaces to help with formatting in permToString()
 o size
Stores the vector's initial size so it can be quickly reset after each call to moveLast().

Constructor Index

 o Perm(int)
Sets the set.

Method Index

 o makePerm(long)
This implementation seems to scale just fine.
 o moveLast(int)
Does a shift of last element to another position in the set
 o permToString()
This method just spaces out the vector elements for display.

Variables

 o size
 private int size
Stores the vector's initial size so it can be quickly reset after each call to moveLast().

 o eighty
 private static final String eighty
Spaces to help with formatting in permToString()

Constructors

 o Perm
 public Perm(int vsize)
Sets the set.

Methods

 o makePerm
 void makePerm(long count)
This implementation seems to scale just fine. On a set of 52 elements, it ran through more than a million permutations (of the 8.07E67 total) in 7 minutes on my P100 OS/2 machine (including display time in the background). Of course, it might still be running if I hadn't interrupted it. A set of 8 elements (40,320 permutations) took less than 40 seconds, not including display time, more than 1,000 per second. PC Magazine(TM) and its PC Labs(TM) Java evaluations, quoted recently in the Wall Street Journal(TM) by a Micro$oft(TM?) lawyer, should take a hike.

 o moveLast
 void moveLast(int newDex)
Does a shift of last element to another position in the set

 o permToString
 String permToString()
This method just spaces out the vector elements for display.