Class MyInteger

  • All Implemented Interfaces:
    java.util.Comparator<MyInteger>

    public class MyInteger
    extends java.lang.Object
    implements java.util.Comparator<MyInteger>
    very simple and fast mutable integer class
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int i
      the int value of this
    • Constructor Summary

      Constructors 
      Constructor Description
      MyInteger​(int _i)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(MyInteger o1, MyInteger o2)  
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Field Detail

      • i

        public int i
        the int value of this
    • Constructor Detail

      • MyInteger

        public MyInteger​(int _i)
        Parameters:
        _i - the initial integer to set this to
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        the value of int as a string
        See Also:
        Object.toString()
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Comparator<MyInteger>
        Overrides:
        equals in class java.lang.Object
        See Also:
        Object.equals(java.lang.Object)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Object.hashCode()
      • compare

        public int compare​(MyInteger o1,
                           MyInteger o2)
        Specified by:
        compare in interface java.util.Comparator<MyInteger>
        Parameters:
        o1 - the first MyInteger
        o2 - the secondMyInteger
        Returns:
        o1-o2
        See Also:
        Comparator.compare(java.lang.Object, java.lang.Object)