<commit_before>package dimesweeper.neighborhoods;

import dimesweeper.INeighborhood;
import dimesweeper.positions.Position;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by EDave on 24.05.2015.
 */
public class Diagonal implements INeighborhood {
	public final static Diagonal instance = new Diagonal ();

	private Diagonal () {
	}

	@Override
	public Set<Position> getNeighborPositions (Position pos, int radius) {
		Set<Position> positions = new HashSet<> ();
		for (; radius >= 1; radius--)
			positions.addAll (getNeighbors (pos, radius));
		return positions;
	}

	public Set<Position> getNeighbors (Position pos, int radius) {
		Set<Position> ret = new HashSet<> ();
		if (pos.getLength () <= 1) {
			int coord = pos.getHead ();
			ret.add (Position.create (coord + radius));
			ret.add (Position.create (coord - radius));
		} else {
			int coord = pos.getHead ();
			Position tailCoords = pos.getTail ();
			for (Position subposition : getNeighbors (tailCoords, radius)) {
				ret.add (subposition.prepend (coord + radius));
				ret.add (subposition.prepend (coord - radius));
			}
		}
		return ret;
	}

}<commit_msg>simplified 'diagonal'<commit_after>package dimesweeper.neighborhoods;

import dimesweeper.INeighborhood;
import dimesweeper.positions.Position;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by EDave on 24.05.2015.
 */

//TODO: rename. vertigonal? maxigonal?
//TODO: make diagonal, triagonal, quadragonal proper
public class Diagonal implements INeighborhood {
	public final static Diagonal instance = new Diagonal ();

	private Diagonal () {
	}

	@Override
	public Set<Position> getNeighborPositions (Position pos, int radius) {
		Set<Position> positions = new HashSet<> ();
		for (; radius >= 1; radius--)
			positions.addAll (getNeighbors (pos, radius));
		return positions;
	}

	public Set<Position> getNeighbors (Position pos, int radius) {
		Set<Position> ret = new HashSet<> ();
		if (pos.isEmpty ()) { ret.add (Position.NIL); }
		else
		{
			int coord = pos.getHead ();
			Position tailCoords = pos.getTail ();
			for (Position subposition : getNeighbors (tailCoords, radius)) {
				ret.add (subposition.prepend (coord + radius));
				ret.add (subposition.prepend (coord - radius));
			}
		}
		return ret;
	}

}
{'fraction_non_alphanumeric': 0.12856516015796401, 'fraction_numerical': 0.008336989907854322, 'mean_word_length': 4.0, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '517565', 'n_tokens_mistral': 824, 'n_tokens_neox': 727, 'n_words': 199}