Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// This Source Code is in the Public Domain per: http://unlicense.org
package org.litesoft.core.util;

import java.util.*;

public class NoEqualsSet<E, C extends Comparable<C>> extends NoEqualsCollection<E, C> implements Set<E>
{
    private final Set<Wrapper<E, C>> mCollection = new HashSet<Wrapper<E, C>>();

    protected NoEqualsSet( NoEqualsHelper<E, C> pHelper )
    {
        super( pHelper );
    }

    public NoEqualsSet( NoEqualsHelper<E, C> pHelper, Collection<? extends E> pInitialEntries )
    {
        this( pHelper );
        if ( pInitialEntries != null )
        {
            E[] zEntries = pInitialEntries.toArray( mHelper.createArray( pInitialEntries.size() ) ); // Snag a copy of the Entries
            for ( E zEntry : zEntries )
            {
                if ( zEntry != null )
                {
                    mCollection.add( wrap( zEntry ) );
                }
            }
        }
    }

    public NoEqualsSet( NoEqualsHelper<E, C> pHelper, E... pInitialEntries )
    {
        this( pHelper, (pInitialEntries != null) ? Arrays.asList( pInitialEntries ) : null );
    }

    @Override
    protected final Collection<Wrapper<E, C>> LLgetCollection()
    {
        return mCollection;
    }

    /**
     * Compares the specified object with this set for equality.
     * <p/>
     * Returns <tt>true</tt> if the specified object is also a set, the two sets
     * have the same size, and every member of the specified set is
     * contained in this set (or equivalently, every member of this set is
     * contained in the specified set).  This definition ensures that the
     * equals method works properly across different implementations of the
     * set interface.
     *
     * @param o object to be compared for equality with this set
     *
     * @return <tt>true</tt> if the specified object is equal to this set
     */
    public final boolean equals( Object o )
    {
        return (o == this) || ((o instanceof Set) && LLequalsNotNull( (Set<?>) o ));
    }

    public final boolean equals( Set<?> them )
    {
        return (them == this) || ((them != null) && LLequalsNotNull( them ));
    }

    private boolean LLequalsNotNull( Set<?> them )
    {
        Object[] theirObjects = them.toArray();
        synchronized ( this )
        {
            if ( LLsize() != theirObjects.length )
            {
                return false;
            }
            if ( theirObjects.length != 0 )
            {
                Wrapper<E, C>[] zWrappers = getWrappedEntries();
                for ( Object zTheirObject : theirObjects )
                {
                    if ( !mHelper.isInstance( zTheirObject ) || !LLobjectIsIn( castNullOK( zTheirObject ), zWrappers ) )
                    {
                        return false;
                    }
                }
            }
        }
        return true;
    }
}

Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/core/util/NoEqualsSet.java

Diff revisions: vs.
Revision Author Commited Message
947 Diff Diff GeorgeS picture GeorgeS Fri 06 Jun, 2014 23:36:56 +0000

Correct Spelling of package!

587 GeorgeS picture GeorgeS Fri 02 Dec, 2011 11:55:12 +0000

Accordion...