<commit_before>import {BaseProxy} from '../proxy/BaseProxy';
import {ISet} from '../ISet';
import * as Q from 'q';
import {ItemListener} from '../core/ItemListener';
import {Data} from '../serialization/Data';

import {SetAddCodec} from '../codec/SetAddCodec';
import {SetAddAllCodec} from '../codec/SetAddAllCodec';
import {SetGetAllCodec} from '../codec/SetGetAllCodec';
import {SetClearCodec} from '../codec/SetClearCodec';
import {SetContainsCodec} from '../codec/SetContainsCodec';
import {SetContainsAllCodec} from '../codec/SetContainsAllCodec';
import {SetIsEmptyCodec} from '../codec/SetIsEmptyCodec';
import {SetRemoveCodec} from '../codec/SetRemoveCodec';
import {SetCompareAndRemoveAllCodec} from '../codec/SetCompareAndRemoveAllCodec';
import {SetCompareAndRetainAllCodec} from '../codec/SetCompareAndRetainAllCodec';
import {SetSizeCodec} from '../codec/SetSizeCodec';
import {SetAddListenerCodec} from '../codec/SetAddListenerCodec';
import {SetRemoveListenerCodec} from '../codec/SetRemoveListenerCodec';
import ClientMessage = require('../ClientMessage');

export class Set<E> extends BaseProxy implements ISet<E> {

    add(entry: E): Q.Promise<boolean> {
        return this.encodeInvokeOnKey<boolean>(SetAddCodec, this.name, this.toData(entry));
    }

    addAll(items: E[]): Q.Promise<boolean> {
        return this.encodeInvokeOnKey<boolean>(SetAddAllCodec, this.name, this.serializeList(items));
    }

    getAll(): Q.Promise<E[]> {
        return this.encodeInvokeOnKey(SetGetAllCodec, this.name)
            .then((items: Array<Data>) => {
                return items.map((item) => {
                    return this.toObject(item);
                });
            });
    }

    clear(): Q.Promise<void> {
        return this.encodeInvokeOnKey<void>(SetClearCodec, this.name);
    }

    contains(entry: E): Q.Promise<boolean> {
        return this.encodeInvokeOnKey<boolean>(SetContainsCodec, this.name, this.toData(entry));
    }

    containsAll(items: E[]): Q.Promise<boolean> {
        return this.encodeInvokeOnKey<boolean>(SetContainsAllCodec, this.name, this.serializeList(items));
    }

    isEmpty(): Q.Promise<boolean> {
        return this.encodeInvokeOnKey<boolean>(SetIsEmptyCodec, this.name);
    }

    remove(entry: E): Q.Promise<boolean> {
        return this.encodeInvokeOnKey<boolean>(SetRemoveCodec, this.name, this.toData(entry));
    }

    removeAll(items: E[]): Q.Promise<boolean> {
        return this.encodeInvokeOnKey<boolean>(SetCompareAndRemoveAllCodec, this.name, this.serializeList(items));
    }

    retainAll(items: E[]): Q.Promise<boolean> {
        return this.encodeInvokeOnKey<boolean>(SetCompareAndRetainAllCodec, this.name, this.serializeList(items));
    }

    size(): Q.Promise<number> {
        return this.encodeInvokeOnKey<number>(SetSizeCodec, this.name);
    }

    addItemListener(listener: ItemListener<E>, includeValue: boolean = true): Q.Promise<string> {<commit_msg>extend set proxy from PartitionSpecificProxy (#106)<commit_after>import {ISet} from '../ISet';
import * as Q from 'q';
import {ItemListener} from '../core/ItemListener';
import {Data} from '../serialization/Data';

import {SetAddCodec} from '../codec/SetAddCodec';
import {SetAddAllCodec} from '../codec/SetAddAllCodec';
import {SetGetAllCodec} from '../codec/SetGetAllCodec';
import {SetClearCodec} from '../codec/SetClearCodec';
import {SetContainsCodec} from '../codec/SetContainsCodec';
import {SetContainsAllCodec} from '../codec/SetContainsAllCodec';
import {SetIsEmptyCodec} from '../codec/SetIsEmptyCodec';
import {SetRemoveCodec} from '../codec/SetRemoveCodec';
import {SetCompareAndRemoveAllCodec} from '../codec/SetCompareAndRemoveAllCodec';
import {SetCompareAndRetainAllCodec} from '../codec/SetCompareAndRetainAllCodec';
import {SetSizeCodec} from '../codec/SetSizeCodec';
import {SetAddListenerCodec} from '../codec/SetAddListenerCodec';
import {SetRemoveListenerCodec} from '../codec/SetRemoveListenerCodec';
import ClientMessage = require('../ClientMessage');
import {PartitionSpecificProxy} from './PartitionSpecificProxy';

export class Set<E> extends PartitionSpecificProxy implements ISet<E> {

    add(entry: E): Q.Promise<boolean> {
        return this.encodeInvoke<boolean>(SetAddCodec, this.toData(entry));
    }

    addAll(items: E[]): Q.Promise<boolean> {
        return this.encodeInvoke<boolean>(SetAddAllCodec, this.serializeList(items));
    }

    getAll(): Q.Promise<E[]> {
        return this.encodeInvoke(SetGetAllCodec)
            .then((items: Array<Data>) => {
                return items.map((item) => {
                    return this.toObject(item);
                });
            });
    }

    clear(): Q.Promise<void> {
        return this.encodeInvoke<void>(SetClearCodec);
    }

    contains(entry: E): Q.Promise<boolean> {
        return this.encodeInvoke<boolean>(SetContainsCodec, this.toData(entry));
    }

    containsAll(items: E[]): Q.Promise<boolean> {
        return this.encodeInvoke<boolean>(SetContainsAllCodec, this.serializeList(items));
    }

    isEmpty(): Q.Promise<boolean> {
        return this.encodeInvoke<boolean>(SetIsEmptyCodec);
    }

    remove(entry: E): Q.Promise<boolean> {
        return this.encodeInvoke<boolean>(SetRemoveCodec, this.toData(entry));
    }

    removeAll(items: E[]): Q.Promise<boolean> {
        return this.encodeInvoke<boolean>(SetCompareAndRemoveAllCodec, this.serializeList(items));
    }

    retainAll(items: E[]): Q.Promise<boolean> {
        return this.encodeInvoke<boolean>(SetCompareAndRetainAllCodec, this.serializeList(items));
    }

    size(): Q.Promise<number> {
        return this.encodeInvoke<number>(SetSizeCodec);
    }

    addItemListener(listener: ItemListener<E>, includeValue: boolean = true): Q.Promise<string> {
{'fraction_non_alphanumeric': 0.14520027624309392, 'fraction_numerical': 0.0005179558011049724, 'mean_word_length': 4.072679509632224, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5676499', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1727, 'n_words': 322}