public int compare()

in mavibot/src/main/java/org/apache/directory/mavibot/btree/comparator/ShortArrayComparator.java [51:134]


    public int compare( short[] shortArray1, short[] shortArray2 )
    {
        if ( shortArray1 == shortArray2 )
        {
            return 0;
        }

        if ( shortArray1 == null )
        {
            if ( shortArray2 == null )
            {
                return 0;
            }
            else
            {
                return -1;
            }
        }
        else
        {
            if ( shortArray2 == null )
            {
                return 1;
            }
            else
            {
                if ( shortArray1.length < shortArray2.length )
                {
                    int pos = 0;

                    for ( short short1 : shortArray1 )
                    {
                        short short2 = shortArray2[pos];

                        if ( short1 == short2 )
                        {
                            pos++;
                        }
                        else if ( short1 < short2 )
                        {
                            return -1;
                        }
                        else
                        {
                            return 1;
                        }
                    }

                    return -1;
                }
                else
                {
                    int pos = 0;

                    for ( short short2 : shortArray2 )
                    {
                        short short1 = shortArray1[pos];

                        if ( short1 == short2 )
                        {
                            pos++;
                        }
                        else if ( short1 < short2 )
                        {
                            return -1;
                        }
                        else
                        {
                            return 1;
                        }
                    }

                    if ( pos < shortArray1.length )
                    {
                        return 1;
                    }
                    else
                    {
                        return 0;
                    }
                }
            }
        }
    }