Updated the readme file

This commit is contained in:
2020-06-07 23:40:59 -04:00
parent 9829b8dc29
commit 05b3fac948

View File

@@ -1,12 +1,24 @@
# JavaClasses # JavaClasses
This is a set of classes and functions, not part of the standard library, that I have found it helpful to keep around. This is a set of classes and functions, not part of the standard library, that I have found it helpful to keep around.
#Stopwatch # Installation
In order to use these in a program they need to be installed with maven. I normally use `mvn clean package install`. From there you can import them into a maven project using
```XML
<dependency>
<groupId>mattrixwv</groupId>
<artifactId>myClasses</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
```
Then import them into a program by `import mattrixwv.Algorithms;` or `import mattrixwv.Stopwatch;`.
# Stopwatch
This is a class that allows you to determine the execution time of an algorithm. This is a class that allows you to determine the execution time of an algorithm.
You can get specific resolutions of time through their own get functions, all of which return double. You can get specific resolutions of time through their own get functions, all of which return double.
However I have built it a function, getStr(), that automatically chooses the best resolution and returns both the number and resolution as a string. However I have built it a function, getStr(), that automatically chooses the best resolution and returns both the number and resolution as a string.
This is used extensively in my ProjectEuler code found at https://bitbucket.org/Mattrixwv/ProjectEuler
Example of usage: Example of usage:
```Java
Stopwatch timer = new Stopwatch(); Stopwatch timer = new Stopwatch();
timer.start(); timer.start();
//Code to time here //Code to time here
@@ -14,18 +26,8 @@ Example of usage:
System.out.printf("It took %s to run this algorithm", timer.getStr()); System.out.printf("It took %s to run this algorithm", timer.getStr());
//You could also do something like this if you prefered //You could also do something like this if you prefered
System.out.printf("It took %f milliseconds to run this algorithm", timer.getMilli()); System.out.printf("It took %f milliseconds to run this algorithm", timer.getMilli());
```
#Algorithms # Algorithms
This is a class that contains many different algorithms that I have found it useful to keep around. This is a class that contains many different algorithms that I have found it useful to keep around. This is used extensively in my ProjectEuler code found at https://bitbucket.org/Mattrixwv/ProjectEuler
All algorithms are overloaded to allow for using both Integer and BigInteger types. All methods are overloaded to allow for using Integer, Long, and BigInteger types.
Examples of usage:
primes = getPrimes(topNum); //primes now holds all primes less than or equal to topNum
primes = getNumPrimes(numPrimes); //primes now holds an ArrayList containing the first numPrimes prime numbers
factors = getFactors(number); //factors now holds an ArrayList containing the factors of number
divisors = getDivisors(number); //divisors now holds an ArrayList containing all the divisors of number
fib = getFib(number); //fib now holds the number element in the fibonacci sequence
fib = getAllFib(highestNumber); //fib now holds an ArrayList containing all fibonacci numbers less than or equal to highestNumber
sum = getSum(numbers); //sum now holds the sum of all elements in the ArrayList numbers
sum = getBigSum(numbers): //Same as getSum, but for BigInteger
prod = getProd(numbers); //prod now holds the product of all elements in the ArrayList numbers
prod = getBigProd(numbers); //Same as getProd, but for BigInteger