24 package org.lightjason.agentspeak.consistency.metric;
28 import java.util.Collection;
29 import java.util.HashSet;
30 import java.util.stream.Collectors;
31 import java.util.stream.Stream;
43 public final Double
apply(
final Stream<? extends ITerm> p_first,
final Stream<? extends ITerm> p_second )
45 final Collection<ITerm> l_first = p_first.collect( Collectors.toCollection( HashSet<ITerm>::new ) );
46 final Collection<ITerm> l_second = p_second.collect( Collectors.toCollection( HashSet<ITerm>::new ) );
48 return (
double) Stream.concat( l_first.stream(), l_second.stream() )
52 .filter( i -> !( l_first.contains( i ) && ( l_second.contains( i ) ) ) )
metric interface of the coherency structure
final Double apply(final Stream<? extends ITerm > p_first, final Stream<? extends ITerm > p_second)
metric on collections returns the size of symmetric difference