IdentityDictionary.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 java.util.IdentityHashMap;
import Hoot.Behaviors.Ordered;
import Smalltalk.Core.Subject;
import Smalltalk.Magnitudes.Ordinal;
import Smalltalk.Collections.Collected;
public class IdentityDictionary<KeyType extends Magnitude, ElementType extends Object> extends Dictionary<KeyType, ElementType>
{
public static Metaclass type() { return (Metaclass)Metaclass.$class; }
@Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
public static class Metaclass extends Dictionary.Metaclass
{
static final IdentityDictionary.Metaclass $class = new IdentityDictionary.Metaclass();
public Metaclass() {
this(IdentityDictionary.Metaclass.class);
}
public Metaclass(java.lang.Class aClass) {
super(aClass);
}
@Override public java.lang.Class outerClass() { return IdentityDictionary.class; }
/**
* @return
*/
@Override public IdentityDictionary $new()
{
java.lang.String exitID = "IdentityDictionaryMetatype>>$new";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (IdentityDictionary)f0.exit(exitID, this.$new(SmallInteger.from(10)));
});
}
/**
* @return
*/
@Override public IdentityDictionary $new(final Ordinal capacity)
{
java.lang.String exitID = "IdentityDictionaryMetatype>>$new";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (IdentityDictionary)f0.exit(exitID, new IdentityDictionary(capacity));
});
}
/**
* @return
*/
@Override public IdentityDictionary from(final java.util.Map primitiveMap)
{
java.lang.String exitID = "IdentityDictionaryMetatype>>from";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (IdentityDictionary)f0.exit(exitID, new IdentityDictionary(primitiveMap));
});
}
}
/**
*
*/
protected IdentityDictionary()
{
java.lang.String exitID = "IdentityDictionary>>IdentityDictionary";
Frame f0 = new Frame(exitID);
contents = new IdentityHashMap();
}
/**
*
*/
protected IdentityDictionary(final Ordinal capacity)
{
java.lang.String exitID = "IdentityDictionary>>IdentityDictionary";
Frame f0 = new Frame(exitID);
contents = new IdentityHashMap(capacity.intValue());
}
/**
*
*/
protected IdentityDictionary(final java.util.Map primitiveMap)
{
java.lang.String exitID = "IdentityDictionary>>IdentityDictionary";
Frame f0 = new Frame(exitID);
contents = new IdentityHashMap(primitiveMap.size());
contents.putAll(primitiveMap);
}
/**
* @return
*/
@Override public Set<KeyType> keys()
{
java.lang.String exitID = "IdentityDictionary>>keys";
Frame f0 = new Frame(exitID);
java.util.Set<KeyType> s = contents.keySet();
{
IdentitySet prime = (IdentitySet)IdentitySet.type().$new(SmallInteger.from(s.size()));
prime.addAll(Set.from(s));
return prime.yourself();
}
}
/**
* @return
*/
public Boolean equals(final IdentityDictionary aCollection)
{
java.lang.String exitID = "IdentityDictionary>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)Boolean.from(contents.equals(aCollection.primitiveContents()));
}
/**
* @return
*/
@Override public Boolean equals(final Collected aCollection)
{
java.lang.String exitID = "IdentityDictionary>>equals";
Frame f0 = new Frame(exitID);
return (Boolean)IdentityDictionary.type().accepts(aCollection).and(Predicate.with(f2 -> {
return (this.equals(((IdentityDictionary)aCollection)));
}, ""));
}
}