Java

Custom String Hashing – Part II

In this post, the second of two, we will discuss the re-implementation of all necessary classes to provide “internal” Java support for custom hashing. In all, five classes (java.util.HashMap, java.util.HashSet, java.util.AbstractMap, java.util.LinkedHashMap, and java.util.LinkedHashSet) must be handled. The benefit of this approach is minimal alterations to existing code. That is, instead of importing from java.util.HashMap, […]

Custom String Hashing – Part II Read More »

Logging

In this post, I’m going to share my custom logging class. It can be seen as a scaled down version of log4j, which is a comprehensive logging application. While log4j is great, it is not easily added to ones program. I’ve used log4j before and found it very helpful in large applications, but when I’m

Logging Read More »

JNI Basics

JNI stands for Java Native Interface (detailed Oracle documentation). It allows Java to execute code written in other languages such as C/C++ and assembly. So, why would you want to do this? While Java is quite comprehensive, it is by design generic. That is, it must operate seamlessly across all supported architectures (and there are

JNI Basics Read More »

Combinations

A quick Google search for Java combination generators produces many results; nearly all focus on recursion (for more on recursion, see this post). While suitable for smaller sets, deep recursion quickly saturates the recursive stack, crashing Java. Thus, an iterative approach is warranted. In this post, both recursive and iterative approaches are shown.

Combinations Read More »

Recursion

Recursion is a programming technique that deconstructs a large process into a series of small, identical steps. Thus, a single method is created that continually calls itself to solve the next iteration by altering the parameters. This continues until some termination criterion is reached. While recursion is a useful tool, it requires additional memory to

Recursion Read More »

Counting sort

Counting sort in an \(O\left(n+m\right)\) sorting algorithm (instead of the usual \(O\left(n\log n\right)\)) for integer values, where \(n\) is the number of elements to sort and \(m\) is the width of the data type (e.g., \(2^{8}\) for byte). Its premise is quite simple. Given enough memory, it creates an array the width of the data

Counting sort Read More »

Command line reader

While appearing “old-fashioned,” command line programs still exist and are quite useful. In this post, I will share my little command line reader, which provides a few simple readers. It accepts prompt text and handles plaintext and password entry. While the former is quite simple, the latter requires a little background to avoid common mistakes.

Command line reader Read More »