IdentitySet.java
/**
* Copyright 2010,2021 Nikolas S Boyd.
Permission is granted to copy this work provided this copyright statement is retained in all copies.
*/
package Hoot.Collections;
import Hoot.Runtime.Functions.*;
import Hoot.Runtime.Faces.*;
import Hoot.Runtime.Values.*;
import Hoot.Runtime.Blocks.*;
import Smalltalk.Core.*;
import Smalltalk.Blocks.*;
import Smalltalk.Magnitudes.*;
import Hoot.Behaviors.*;
import Hoot.Behaviors.Nil;
import Hoot.Behaviors.Object;
import Hoot.Behaviors.True;
import Hoot.Behaviors.False;
import Hoot.Behaviors.Boolean;
import Hoot.Magnitudes.*;
import Hoot.Magnitudes.Integer;
import Hoot.Magnitudes.Character;
import Hoot.Magnitudes.Float;
import Hoot.Magnitudes.Double;
import Hoot.Magnitudes.Integer;
import Smalltalk.Magnitudes.Ordinal;
import Smalltalk.Collections.*;
import Smalltalk.Core.Subject;
import java.util.Collections;
import java.util.IdentityHashMap;
public class IdentitySet<ElementType extends Object> extends Set<ElementType>
{
public static Metaclass type() { return (Metaclass)Metaclass.$class; }
@Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
public static class Metaclass extends Set.Metaclass
{
static final IdentitySet.Metaclass $class = new IdentitySet.Metaclass();
public Metaclass() {
this(IdentitySet.Metaclass.class);
}
public Metaclass(java.lang.Class aClass) {
super(aClass);
}
@Override public java.lang.Class outerClass() { return IdentitySet.class; }
/**
* @return
*/
@Override public IdentitySet $new()
{
java.lang.String exitID = "IdentitySetMetatype>>$new";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (IdentitySet)f0.exit(exitID, this.$new(SmallInteger.from(10)));
});
}
/**
* @return
*/
@Override public IdentitySet $new(final Ordinal capacity)
{
java.lang.String exitID = "IdentitySetMetatype>>$new";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (IdentitySet)f0.exit(exitID, new IdentitySet(capacity));
});
}
/**
* @return
*/
public IdentitySet from(final java.util.Set primitiveSet)
{
java.lang.String exitID = "IdentitySetMetatype>>from";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (IdentitySet)f0.exit(exitID, new IdentitySet(primitiveSet, False.literal()));
});
}
/**
* @return
*/
@Override public IdentitySet synchronizedFrom(final java.util.Set primitiveSet)
{
java.lang.String exitID = "IdentitySetMetatype>>synchronizedFrom";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (IdentitySet)f0.exit(exitID, new IdentitySet(primitiveSet, True.literal()));
});
}
}
/**
*
*/
protected IdentitySet()
{
java.lang.String exitID = "IdentitySet>>IdentitySet";
Frame f0 = new Frame(exitID);
contents = Collections.newSetFromMap(new IdentityHashMap());
}
/**
*
*/
protected IdentitySet(final Ordinal capacity)
{
java.lang.String exitID = "IdentitySet>>IdentitySet";
Frame f0 = new Frame(exitID);
contents = Collections.newSetFromMap(new IdentityHashMap(capacity.intValue()));
}
/**
*
*/
protected IdentitySet(final java.util.Set primitiveSet, final Boolean syncSet)
{
this(SmallInteger.from(primitiveSet.size()));
java.lang.String exitID = "IdentitySet>>IdentitySet";
Frame f0 = new Frame(exitID);
syncSet.ifTrue(Closure.with(f2 -> {
contents = Collections.synchronizedSet(contents);
}, ""));
this.addAll(Set.from(primitiveSet));
}
}