Package org.grouplens.lenskit.collections

Examples of org.grouplens.lenskit.collections.LongKeyDomain


    protected MutableTypedSideChannel<String> emptyDomainSideChannel() {
        return new MutableTypedSideChannel<String>(LongKeyDomain.empty());
    }
   
    protected MutableTypedSideChannel<String> emptySideChannel() {
        LongKeyDomain keys = LongKeyDomain.create(1, 2, 4);
        return new MutableTypedSideChannel<String>(keys);
    }
View Full Code Here


        LongKeyDomain keys = LongKeyDomain.create(1, 2, 4);
        return new MutableTypedSideChannel<String>(keys);
    }
   
    protected MutableTypedSideChannel<String> simpleSideChannel() {
        LongKeyDomain keys = LongKeyDomain.create(1, 2, 4);
        String[] values = {a,b,a};
        return new MutableTypedSideChannel<String>(keys,values);
    }
View Full Code Here

    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Override
    public MutableSparseVector mutableCopy() {
        LongKeyDomain mks = keys.clone();
        double[] mvs = Arrays.copyOf(values, keys.domainSize());
        MutableSparseVector result = new MutableSparseVector(mks, mvs);
        for (Map.Entry<Symbol, ImmutableSparseVector> entry : channelVectors.entrySet()) {
            result.addVectorChannel(entry.getKey(), entry.getValue().mutableCopy());
        }
View Full Code Here

        String[] values = {a,b,a};
        return new MutableTypedSideChannel<String>(keys,values);
    }
   
    protected MutableTypedSideChannel<String> singletonSideChannel() {
        LongKeyDomain keys = LongKeyDomain.create(1);
        String[] values = {a};
        return new MutableTypedSideChannel<String>(keys,values);
    }
View Full Code Here

        return new MutableTypedSideChannel<String>(keys,values);
    }
   
    @Test
    public void testConstructors() {
        LongKeyDomain keys = LongKeyDomain.create(1, 2);
        MutableTypedSideChannel<String> channel = new MutableTypedSideChannel<String>(keys.clone());
        assertTrue(channel.isEmpty());
       
        channel = new MutableTypedSideChannel<String>(keys.clone(), new String[]{a,b});
        assertFalse(channel.isEmpty());
        assertEquals(a, channel.get(1));
        assertEquals(b, channel.get(2));

        keys.setActive(0, false);
        channel = new MutableTypedSideChannel<String>(keys.clone(), new String[]{null,b});
        assertFalse(channel.isEmpty());
        assertEquals(b,channel.get(2));
        assertNull(channel.get(1));
        channel.put(1, a); //check if this is in domain.

        channel = new MutableTypedSideChannel<String>(keys.clone(), new String[]{null,b,c});
        assertFalse(channel.isEmpty());
        assertEquals(b,channel.get(2));
        assertNull(channel.get(1));
        assertNull(channel.get(3));
        channel.put(1, a); //check if this is in domain.
View Full Code Here

   
    @Test
    public void testWithDomain() {
        MutableTypedSideChannel<String> simple = simpleSideChannel();
        simple.remove(1);
        LongKeyDomain keys = LongKeyDomain.create(1, 2, 3);
        MutableTypedSideChannel<String> subset = simple.withDomain(keys);
       
        //simple is unchanged
        assertFalse(simple.containsKey(3));
        assertFalse(simple.containsKey(1));
View Full Code Here

     * @param freeze If {@code true}, try to re-use this storage. If this option is set, then this
     *               map will be unusable after this method has been called.
     * @return The new, immutable map.
     */
    public TypedSideChannel<V> immutable(LongKeyDomain domain, boolean freeze) {
        LongKeyDomain nks = domain.clone();
        V[] nvs;
        nvs = adjustStorage(nks, freeze);
        frozen |= freeze;
        return new TypedSideChannel<V>(nks, nvs, defaultReturnValue());
    }
View Full Code Here

     *
     * @param domain The domain to use.
     * @return The new map.
     */
    public MutableTypedSideChannel<V> withDomain(LongKeyDomain domain) {
        LongKeyDomain nks = domain.clone();
        V[] nvs = adjustStorage(nks, false);
        MutableTypedSideChannel<V> copy = new MutableTypedSideChannel<V>(nks, nvs, defaultReturnValue());
        copy.defaultReturnValue(defaultReturnValue());
        return copy;
    }
View Full Code Here

    protected TypedSideChannel<String> emptyDomainSideChannel() {
        return new TypedSideChannel<String>(LongKeyDomain.empty());
    }
   
    protected TypedSideChannel<String> emptySideChannel() {
        LongKeyDomain keys = LongKeyDomain.create(1, 2, 4);
        return new TypedSideChannel<String>(keys);
    }
View Full Code Here

        LongKeyDomain keys = LongKeyDomain.create(1, 2, 4);
        return new TypedSideChannel<String>(keys);
    }
   
    protected TypedSideChannel<String> simpleSideChannel() {
        LongKeyDomain keys = LongKeyDomain.create(1, 2, 4);
        String[] values = {a,b,a};
        return new TypedSideChannel<String>(keys,values);
    }
View Full Code Here

TOP

Related Classes of org.grouplens.lenskit.collections.LongKeyDomain

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.