Reconstruct the {@link ConciseSet} instance from a stream
776789
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
  {
    s.defaultReadObject();
    firstEmptyWord = words.length;
    size = -1;
  }
136359
private void loadStopWords(Set<String> set, InputStream in){
		BufferedReader bufr;
		try
		{
			bufr = new BufferedReader(new InputStreamReader(in));
			String line=null;
			while((line=bufr.readLine())!=null) {
				set.add(line.trim());
			}
			try
			{
				bufr.close();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
937279
public <U> SimpleReactStream<U> from(final Stream<U> stream) {

        final Stream s = stream.map(it -> CompletableFuture.completedFuture(it));
        return construct(s);
    }
236141
@Override
  public Set<Entry<K, Collection<V>>> entrySet() {
    return new AbstractSet<Entry<K, Collection<V>>>() {
      @Override
      public Iterator<Map.Entry<K, Collection<V>>> iterator() {
        Filter<Map.Entry<K, Collection<V>>> filter1 = new Filter<Map.Entry<K, Collection<V>>>() {
          private static final long serialVersionUID = -3257173354412718639L;

          // only accepts stuff not overwritten by deltaMap
          public boolean accept(Map.Entry<K, Collection<V>> e) {
            K key = e.getKey();
            if (deltaMap.containsKey(key)) {
              return false;
            }
            return true;
          }
        };

        Iterator<Map.Entry<K, Collection<V>>> iter1 = new FilteredIterator<Map.Entry<K, Collection<V>>>(originalMap.entrySet().iterator(), filter1);

        Filter<Map.Entry<K, Collection<V>>> filter2 = new Filter<Map.Entry<K, Collection<V>>>() {
          private static final long serialVersionUID = 1L;

          // only accepts stuff not overwritten by deltaMap
          public boolean accept(Map.Entry<K, Collection<V>> e) {
            if (e.getValue() == removedValue) {
              return false;
            }
            return true;
          }
        };


        Iterator<Map.Entry<K, Collection<V>>> iter2 = new FilteredIterator<Map.Entry<K, Collection<V>>>(deltaMap.entrySet().iterator(), filter2);

        return new ConcatenationIterator<Map.Entry<K, Collection<V>>>(iter1, iter2);
      }

      @Override
      public int size() {
        int size = 0;
        for (// @SuppressWarnings("unused")  // this makes javac v1.5 barf!!
             Entry<K, Collection<V>> entry : this) {
          ErasureUtils.noop(entry);
          size++;
        }
        return size;
      }
    };
  }
122352
private ConciseSet performOperation(ConciseSet other, Operator operator)
  {
    // non-empty arguments
    if (this.isEmpty() || other.isEmpty()) {
      return operator.combineEmptySets(this, other);
    }

    // if the two operands are disjoint, the operation is faster
    ConciseSet res = operator.combineDisjointSets(this, other);
    if (res != null) {
      return res;
    }

    // Allocate a sufficient number of words to contain all possible results.
    // NOTE: since lastWordIndex is the index of the last used word in "words",
    // we require "+2" to have the actual maximum required space.
    // In any case, we do not allocate more than the maximum space required
    // for the uncompressed representation.
    // Another "+1" is required to allows for the addition of the last word
    // before compacting.
    res = empty();
    res.words = new int[1 + Math.min(
        this.lastWordIndex + other.lastWordIndex + 2,
        maxLiteralLengthDivision(Math.max(this.last, other.last)) << (simulateWAH ? 1 : 0)
    )];

    // scan "this" and "other"
    WordIterator thisItr = new WordIterator();
    WordIterator otherItr = other.new WordIterator();
    while (true) {
      if (!thisItr.isLiteral) {
        if (!otherItr.isLiteral) {
          int minCount = Math.min(thisItr.count, otherItr.count);
          res.appendFill(minCount, operator.combineLiterals(thisItr.word, otherItr.word));
          //noinspection NonShortCircuitBooleanExpression
          if (!thisItr.prepareNext(minCount) | /* NOT || */ !otherItr.prepareNext(minCount)) {
            break;
          }
        } else {
          res.appendLiteral(operator.combineLiterals(thisItr.toLiteral(), otherItr.word));
          thisItr.word--;
          //noinspection NonShortCircuitBooleanExpression
          if (!thisItr.prepareNext(1) | /* do NOT use "||" */ !otherItr.prepareNext()) {
            break;
          }
        }
      } else if (!otherItr.isLiteral) {
        res.appendLiteral(operator.combineLiterals(thisItr.word, otherItr.toLiteral()));
        otherItr.word--;
        //noinspection NonShortCircuitBooleanExpression
        if (!thisItr.prepareNext() | /* do NOT use  "||" */ !otherItr.prepareNext(1)) {
          break;
        }
      } else {
        res.appendLiteral(operator.combineLiterals(thisItr.word, otherItr.word));
        //noinspection NonShortCircuitBooleanExpression
        if (!thisItr.prepareNext() | /* do NOT use  "||" */ !otherItr.prepareNext()) {
          break;
        }
      }
    }

    // invalidate the size
    res.size = -1;
    boolean invalidLast = true;

    // if one bit string is greater than the other one, we add the remaining
    // bits depending on the given operation.
    switch (operator) {
      case AND:
        break;
      case OR:
        res.last = Math.max(this.last, other.last);
        invalidLast = thisItr.flush(res);
        invalidLast |= otherItr.flush(res);
        break;
      case XOR:
        if (this.last != other.last) {
          res.last = Math.max(this.last, other.last);
          invalidLast = false;
        }
        invalidLast |= thisItr.flush(res);
        invalidLast |= otherItr.flush(res);
        break;
      case ANDNOT:
        if (this.last > other.last) {
          res.last = this.last;
          invalidLast = false;
        }
        invalidLast |= thisItr.flush(res);
        break;
    }

    // remove trailing zeros
    res.trimZeros();
    if (res.isEmpty()) {
      return res;
    }

    // compute the greatest element
    if (invalidLast) {
      res.updateLast();
    }

    // compact the memory
    res.compact();

    return res;
  }
17038
public static final <A> Collection<A> toConcurrentLazyCollection(final Stream<A> stream) {
        return toConcurrentLazyCollection(stream.iterator());
    }
911422
public static <T> Observable.Transformer<T,ImmutableSet<T>> toImmutableSet() {
        return new Observable.Transformer<T, ImmutableSet<T>>() {
            @Override
            public Observable<ImmutableSet<T>> call(Observable<T> source) {
                return source.collect(new Func0<ImmutableSet.Builder<T>>() {
                    @Override
                    public ImmutableSet.Builder<T> call() {
                        return ImmutableSet.builder();
                    }
                }, new Action2<ImmutableSet.Builder<T>, T>() {
                    @Override
                    public void call(ImmutableSet.Builder<T> builder, T t) {
                        builder.add(t);
                    }
                })
                .map(new Func1<ImmutableSet.Builder<T>, ImmutableSet<T>>() {
                    @Override
                    public ImmutableSet<T> call(ImmutableSet.Builder<T> builder) {
                        return builder.build();
                    }
                });
            }
        };
    }
1073066
public static <T> Collector<T, Set<T>> toSet() {
    return new Collector<T, Set<T>>() {
      @Override
      public Set<T> collect(Stream<? extends T> stream) {
        return Sets.newHashSet(stream.iterator());
      }
    };
  }
500943
public BinarySparseDataset parse(String name, InputStream stream) throws IOException, ParseException {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {

           BinarySparseDataset sparse = new BinarySparseDataset(name);
        
           String line = reader.readLine();
           if (line == null) {
                throw new IOException("Empty data source.");
           }
        
           Set<Integer> items = new HashSet<>();
           do {
                line = line.trim();
                if (line.isEmpty()) {
                    continue;
                }

                String[] s = line.split("\\s+");
            
                items.clear();
                for (int i = 0; i < s.length; i++) {
                    items.add(Integer.parseInt(s[i]));
                }

                int j = 0;
                int[] point = new int[items.size()];
                for (int i : items) {
                    point[j++] = i;
                }

                Arrays.sort(point);
                sparse.add(point);
                line = reader.readLine();
            } while (line != null);

            return sparse;
        }
    }
1166121
public static <T> Collection<T> collect(Iterable<T> stream) {
        LinkedList<T> collection = new LinkedList<>();
        for (T e : stream) {
            collection.add(e);
        }
        return collection;
    }
612266
def from_conll(this_class, stream):
        """"""
        stream = iter(stream)
        sentence = this_class()
        for line in stream:
            line = line.strip()
            if line:
                sentence.append(Token.from_conll(line))
            elif sentence:
                return sentence
        return sentence
1012759
@Override
    public Set<Stream> getResultStreams() {
    	Set<Stream> streams = ImmutableSet.of(this.resultStream);
		return streams;
    }
482265
def union(self, streamSet):
        
        if(not isinstance(streamSet,set)) :
            raise TypeError("The union operator parameter must be a set object")
        if(len(streamSet) == 0):
            return self        
        op = self.topology.graph.addOperator("$Union$")
        op.addInputPort(outputPort=self.oport)
        for stream in streamSet:
            op.addInputPort(outputPort=stream.oport)
        oport = op.addOutputPort(schema=self.oport.schema)
        return Stream(self.topology, oport)
1038038
public void reconstitutePtoPSourceStreams(StreamSet streamSet, int startMode ) 
  throws SIRollbackException, SIConnectionLostException, SIResourceException, SIErrorException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "reconstitutePtoPSourceStreams", new Object[] {streamSet, new Integer(startMode)});

    sourceStreamManager.reconstituteStreamSet(streamSet);
    
    // Don't do flush if we are asked to start in recovery mode 
    if(   ((startMode & JsConstants.ME_START_FLUSH ) == JsConstants.ME_START_FLUSH )
       && ((startMode & JsConstants.ME_START_RECOVERY ) == 0 ) )
   {
      this.sendFlushedMessage(null, streamSet.getStreamID());
      // Now change streamID of streamSet
      streamSet.setStreamID(new SIBUuid12());
      // This calls requestUpdate on the StreamSet Item which will
      // cause a callback to the streamSet.getPersistentData() by msgstore
      Transaction tran = messageProcessor.getTXManager().createAutoCommitTransaction();
      try
      {
        streamSet.requestUpdate(tran);
      }
      catch (MessageStoreException e)
      {
         // MessageStoreException shouldn't occur so FFDC.
         FFDCFilter.processException(
         e,
         "com.ibm.ws.sib.processor.impl.PtoPOutputHandler.reconstitutePtoPSourceStreams",
         "1:1883:1.241",
         this);
  
         SibTr.exception(tc, e);
         if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "reconstitutePtoPSourceStreams", "SIStoreException");
         throw new SIResourceException(e);
      }      
    }
        
    NonLockingCursor cursor = null;
    try
    {
      cursor = transmissionItemStream.newNonLockingItemCursor(
        new ClassEqualsFilter(MessageItem.class));
      cursor.allowUnavailableItems();  

      MessageItem msg = (MessageItem)cursor.next();
      while(msg!=null)
      {
        // Change streamID in message to streamID of StreamSet
        // If we are restoring from a stale backup this will
        // and the restoreMessage method puts it on a new SourceStream
        if( msg.getGuaranteedStreamUuid() !=  streamSet.getStreamID())
        {
          msg.setGuaranteedStreamUuid(streamSet.getStreamID());
        }
              
        //add all messages back in to the streams
        if(!(msg.isAdding() || msg.isRemoving()))
        {
          // commit those which are not in doubt
          sourceStreamManager.restoreMessage(msg, true);
        }
        else
        {
          // add to stream in uncommitted state
          sourceStreamManager.restoreMessage(msg, false);
        }
        
        msg = (MessageItem)cursor.next();
      }
      
      // Consolidate all streams which may have been reconstituted
      // This is necessary as messages may have been added out of order
      // This will return a list of the messageStoreIds of all the
      // messages which need to be locked because they are inside the
      // sendWindows of the streams which they were added to and so may
      // already have been sent 
      List msgsToLock = sourceStreamManager.consolidateStreams(startMode);
      
      // Run through locking all messages in list so they won't expire.      
      // watch out as list is Longs msgstore ids
      long msgId = 0;
      MessageItem msgItem = null;
      for (int i = 0; i < msgsToLock.size(); i++)
      {
        msgId = ((Long)msgsToLock.get(i)).longValue();
        msgItem = (MessageItem)transmissionItemStream.findById(msgId); 
        if( msgItem != null )
          msgItem.lockItemIfAvailable(lockID);
        else
        {
          if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            SibTr.debug(tc, "message wasn't there when we tried to lock it");
        }
      }    
    }
    catch (MessageStoreException e)
    {
      // MessageStoreException shouldn't occur so FFDC.
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.impl.PtoPOutputHandler.reconstitutePtoPSourceStreams",
        "1:1956:1.241",
        this);

      SibTr.exception(tc, e);
      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
        new Object[] {
          "com.ibm.ws.sib.processor.impl.PtoPOutputHandler",
          "1:1963:1.241",
          e });

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "reconstitutePtoPSourceStreams", e);

      throw new SIResourceException(
        nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0002",
          new Object[] {
            "com.ibm.ws.sib.processor.impl.PtoPOutputHandler",
            "1:1974:1.241",
            e },
          null),
        e);
    }
    finally
    {
      if (cursor != null)
        cursor.finished();
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())  
      SibTr.exit(tc, "reconstitutePtoPSourceStreams");      
  }
290024
private ExampleSet readDataSet(File in) throws IOException
	{
		logger.info("read the example set");

		//
		ExampleSet inputSet = new SentenceSetCopy();
		inputSet.read(new BufferedReader(new FileReader(in)));

		String trainFrac = parameter.getProperty("train-frac");
		if (trainFrac != null)
		{
			double f = Double.parseDouble(trainFrac);
			logger.info("training original size: " + inputSet.size());
			logger.info("training fraction: " + (100 * f) + "%");
			return inputSet.subSet(0, (int) (inputSet.size() * f));
		}

		return inputSet;
	}
1186653
public Set entrySet() throws ObjectManagerException {
        return new AbstractSetView() {
            public long size() {
                return size;
            }

            public boolean contains(Object object) throws ObjectManagerException {
                if (object instanceof Map.Entry) {
                    Map.Entry entry = (Map.Entry) object;
                    Object v1 = get(entry.getKey()), v2 = entry.getValue();
                    return v1 == null ? v2 == null : v1.equals(v2);
                }
                return false;
            }

            public Iterator iterator() throws ObjectManagerException {
                return makeTreeMapIterator(new AbstractMapEntry.Type() {
                    public Object get(AbstractMapEntry entry) {
                        return entry;
                    }
                });
            }
        };
    }
464293
def extern_store_set(self, context_handle, vals_ptr, vals_len):
    """"""
    c = self._ffi.from_handle(context_handle)
    return c.to_value(OrderedSet(c.from_value(val[0]) for val in self._ffi.unpack(vals_ptr, vals_len)))