20 package net.sf.gridarta.model.autojoin;
22 import java.io.Serializable;
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.IdentityHashMap;
26 import java.util.List;
31 import org.apache.log4j.Category;
32 import org.apache.log4j.Logger;
33 import org.jetbrains.annotations.NotNull;
55 public static final int SIZE = 16;
59 public static final int NORTH = 1;
61 public static final int EAST = 2;
63 public static final int SOUTH = 4;
65 public static final int WEST = 8;
93 final ArrayList<List<R>> newArchetypes =
new ArrayList<>();
95 for (
final List<R> archetypeList :
archetypes) {
96 newArchetypes.add(
validate(archetypeList));
99 if (newArchetypes.size() >
SIZE) {
102 if (newArchetypes.size() <
SIZE) {
106 newArchetypes.trimToSize();
107 this.archetypes = newArchetypes;
119 final ArrayList<R> result =
new ArrayList<>();
120 final Map<R, R> tmp =
new IdentityHashMap<>();
121 for (
final R archetype : archetypeList) {
122 if (archetype ==
null) {
123 throw new IllegalArgumentException(
"can't add null archetype");
126 if (tmp.put(archetype, archetype) !=
null) {
130 result.add(archetype);
132 if (result.isEmpty()) {
145 for (
int i = 0; i <
SIZE; i++) {
151 LOG.warn(
"Error in AutojoinList.get_index: index not found");
162 for (
int i = 0; i <
SIZE; i++) {
178 for (
int i = 0; i <
SIZE; i++) {
180 if (tmp.get(0) != archetype && tmp.contains(archetype)) {
200 return Collections.unmodifiableCollection(
archetypes.get(index));