Java Collections.copy Examples

Java Collections.copy - 17 examples found. These are the top rated real world Java examples of java.util.Collections.copy extracted from open source projects. You can rate examples to help us improve the quality of examples.
 public static List<Uploader> getUnsyncCopy_uploadList() {
   synchronized (uploadList) {
     ArrayList<Uploader> uploadList2 = new ArrayList<Uploader>();
     Collections.copy(uploadList, uploadList2);
     return uploadList2;
   }
 }
  /** initialize this definition with the other, sort of like a copy constructor */
  public void initializeFrom(WidgetDefinition definition) throws Exception {
    super.initializeFrom(definition);

    if (definition instanceof AggregateFieldDefinition) {
      AggregateFieldDefinition other = (AggregateFieldDefinition) definition;

      this.combineExpr = other.combineExpr;
      this.splitRegexp = other.splitRegexp;
      this.splitPattern = other.splitPattern;
      this.splitFailMessage = other.splitFailMessage;

      Iterator defs = other.container.getWidgetDefinitions().iterator();
      while (defs.hasNext()) {
        container.addWidgetDefinition((WidgetDefinition) defs.next());
      }

      Collections.copy(this.splitMappings, other.splitMappings);

      Iterator fields = other.mappedFields.iterator();
      while (fields.hasNext()) {
        this.mappedFields.add(fields.next());
      }

    } else {
      throw new Exception(
          "Definition to inherit from is not of the right type! (at " + getLocation() + ")");
    }
  }
Example #3
0
 public List<TangibleObject> getDefendersListClone() {
   synchronized (objectMutex) {
     List<TangibleObject> returnList = new Vector<TangibleObject>();
     Collections.copy(returnList, defendersList);
     return returnList;
   }
 }
Example #4
0
  public static void main(String[] args) {

    List src1 = new ArrayList(3);
    src1.add("a");
    src1.add("b");
    src1.add("c");

    List des1 = new ArrayList(3);
    System.out.println(des1.size()); // 是0,而不是3.只有在add或者remove时才会改变,3只代表它的容纳能力是3,而非大小
    Collections.copy(des1, src1);
  }
 public void resumeSuggestionOnLastComposedWord(final LastComposedWord lastComposedWord) {
   mEvents.clear();
   Collections.copy(mEvents, lastComposedWord.mEvents);
   mInputPointers.set(lastComposedWord.mInputPointers);
   mCombinerChain.reset();
   refreshTypedWordCache();
   mCapitalizedMode = lastComposedWord.mCapitalizedMode;
   mAutoCorrection = null; // This will be filled by the next call to updateSuggestion.
   mCursorPositionWithinWord = mCodePointSize;
   mRejectedBatchModeSuggestion = null;
   mIsResumed = true;
 }
Example #6
0
  public static void main(String[] args) {

    // ̽¾¿copyµÄdz¸´ÖÆ
    List<String> list1 = Arrays.asList("red", "green", "blue");
    List<String> list2 = Arrays.asList("pink", "sdfdsf");

    Collections.copy(list1, list2);
    System.out.println(list1);
    System.out.println(list2);
    list2.set(0, "brown");
    System.out.println(list1);
    System.out.println(list2);
  }