Skip to content

Commit

Permalink
Update API
Browse files Browse the repository at this point in the history
  • Loading branch information
glorieux-f committed Aug 18, 2024
1 parent 6b2e049 commit a5d8507
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/main/java/com/github/oeuvres/alix/util/IntList.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
package com.github.oeuvres.alix.util;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;

import com.github.oeuvres.alix.maths.Calcul;

Expand Down Expand Up @@ -339,11 +341,11 @@ public int[] toSet()
{
final int[] dst = new int[size];
int dstPos = 0;
IntIntMap map = new IntIntMap(size);
Set<Integer> set = new HashSet<>(size);
for (int srcPos = 0; srcPos < size; srcPos++) {
final int value = data[srcPos];
if (map.contains(value)) continue;
map.put(value, 1);
if (set.contains(value)) continue;
set.add(value);
dst[dstPos++] = value;
}
return Arrays.copyOf(dst, dstPos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import static org.junit.Assert.*;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

public class EdgeMatrixTest
Expand All @@ -11,8 +14,10 @@ public class EdgeMatrixTest
public void record()
{
int[] events = {1, 2, 3, 1, 2, 5, -4, 1, 2, 1, 3, 7, 8, 1, 3};
int[] nodes = new int[]{3,1};
EdgeMatrix matrix = new EdgeMatrix(nodes, false);
Map<Integer, Long> nodes = new HashMap<>();
nodes.put(3, 3L);
nodes.put(1, 5L);
EdgeMatrix matrix = new EdgeMatrix(nodes, 15, false);
int previous = -1;
for (int position = 0, max = events.length; position < max; position++) {
final int nodeValue = events[position];
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/github/oeuvres/alix/util/EdgeRoller.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public EdgeRoller(int[] words, final int distance) {
this.freq = new long[words.length];
this.uniqs = new boolean[words.length];
this.distance = distance;
this.matrix = new EdgeMatrix(words, directed);
this.matrix = null;
}

/**
Expand Down

0 comments on commit a5d8507

Please sign in to comment.