resources/src/main/java/org/robolectric/res/android/CppAssetManager.java
void mergeInfoLocked(Ref<SortedVector<AssetDir.FileInfo>> pMergedInfoRef,
      final SortedVector<AssetDir.FileInfo> pContents) {
      /*
       * Merge what we found in this directory with what we found in
       * other places.
       *
       * Two basic approaches:
       * (1) Create a new array that holds the unique values of the two
       *     arrays.
       * (2) Take the elements from pContents and shove them into pMergedInfo.
       *
       * Because these are vectors of complex objects, moving elements around
       * inside the vector requires finalructing new objects and allocating
       * storage for members.  With approach #1, we're always adding to the
       * end, whereas with #2 we could be inserting multiple elements at the
       * front of the vector.  Approach #1 requires a full copy of the
       * contents of pMergedInfo, but approach #2 requires the same copy for
       * every insertion at the front of pMergedInfo.
       *
       * (We should probably use a SortedVector interface that allows us to
       * just stuff items in, trusting us to maintain the sort order.)
       */
    SortedVector<AssetDir.FileInfo> pNewSorted;
    int mergeMax, contMax;
    int mergeIdx, contIdx;

    SortedVector<AssetDir.FileInfo> pMergedInfo = pMergedInfoRef.get();
    pNewSorted = new SortedVector<>();
    mergeMax = pMergedInfo.size();
    contMax = pContents.size();
    mergeIdx = contIdx = 0;

    while (mergeIdx < mergeMax || contIdx < contMax) {
      if (mergeIdx == mergeMax) {
              /* hit end of "merge" list, copy rest of "contents" */
        pNewSorted.add(pContents.itemAt(contIdx));
        contIdx++;
      } else if (contIdx == contMax) {
              /* hit end of "cont" list, copy rest of "merge" */
        pNewSorted.add(pMergedInfo.itemAt(mergeIdx));
        mergeIdx++;
      } else if (pMergedInfo.itemAt(mergeIdx) == pContents.itemAt(contIdx)) {
              /* items are identical, add newer and advance both indices */
        pNewSorted.add(pContents.itemAt(contIdx));
        mergeIdx++;
        contIdx++;
      } else if (pMergedInfo.itemAt(mergeIdx).isLessThan(pContents.itemAt(contIdx))) {
              /* "merge" is lower, add that one */
        pNewSorted.add(pMergedInfo.itemAt(mergeIdx));
        mergeIdx++;
      } else {
              /* "cont" is lower, add that one */
        assert (pContents.itemAt(contIdx).isLessThan(pMergedInfo.itemAt(mergeIdx)));
        pNewSorted.add(pContents.itemAt(contIdx));
        contIdx++;
      }
    }

      /*
       * Overwrite the "merged" list with the new stuff.
       */
    pMergedInfoRef.set(pNewSorted);

//  #if 0       // for Vector, rather than SortedVector
//      int i, j;
//      for (i = pContents.size() -1; i >= 0; i--) {
//          boolean add = true;
//
//          for (j = pMergedInfo.size() -1; j >= 0; j--) {
//              /* case-sensitive comparisons, to behave like UNIX fs */
//              if (strcmp(pContents.itemAt(i).mFileName,
//                         pMergedInfo.itemAt(j).mFileName) == 0)
//              {
//                  /* match, don't add this entry */
//                  add = false;
//                  break;
//              }
//          }
//
//          if (add)
//              pMergedInfo.add(pContents.itemAt(i));
//      }
//  #endif
  }
void mergeInfoLocked(Ref<SortedVector<AssetDir.FileInfo>> pMergedInfoRef,
      final SortedVector<AssetDir.FileInfo> pContents) {
      /*
       * Merge what we found in this directory with what we found in
       * other places.
       *
       * Two basic approaches:
       * (1) Create a new array that holds the unique values of the two
       *     arrays.
       * (2) Take the elements from pContents and shove them into pMergedInfo.
       *
       * Because these are vectors of complex objects, moving elements around
       * inside the vector requires finalructing new objects and allocating
       * storage for members.  With approach #1, we're always adding to the
       * end, whereas with #2 we could be inserting multiple elements at the
       * front of the vector.  Approach #1 requires a full copy of the
       * contents of pMergedInfo, but approach #2 requires the same copy for
       * every insertion at the front of pMergedInfo.
       *
       * (We should probably use a SortedVector interface that allows us to
       * just stuff items in, trusting us to maintain the sort order.)
       */
    SortedVector<AssetDir.FileInfo> pNewSorted;
    int mergeMax, contMax;
    int mergeIdx, contIdx;

    SortedVector<AssetDir.FileInfo> pMergedInfo = pMergedInfoRef.get();
    pNewSorted = new SortedVector<>();
    mergeMax = pMergedInfo.size();
    contMax = pContents.size();
    mergeIdx = contIdx = 0;

    while (mergeIdx < mergeMax || contIdx < contMax) {
      if (mergeIdx == mergeMax) {
              /* hit end of "merge" list, copy rest of "contents" */
        pNewSorted.add(pContents.itemAt(contIdx));
        contIdx++;
      } else if (contIdx == contMax) {
              /* hit end of "cont" list, copy rest of "merge" */
        pNewSorted.add(pMergedInfo.itemAt(mergeIdx));
        mergeIdx++;
      } else if (pMergedInfo.itemAt(mergeIdx) == pContents.itemAt(contIdx)) {
              /* items are identical, add newer and advance both indices */
        pNewSorted.add(pContents.itemAt(contIdx));
        mergeIdx++;
        contIdx++;
      } else if (pMergedInfo.itemAt(mergeIdx).isLessThan(pContents.itemAt(contIdx))) {
              /* "merge" is lower, add that one */
        pNewSorted.add(pMergedInfo.itemAt(mergeIdx));
        mergeIdx++;
      } else {
              /* "cont" is lower, add that one */
        assert (pContents.itemAt(contIdx).isLessThan(pMergedInfo.itemAt(mergeIdx)));
        pNewSorted.add(pContents.itemAt(contIdx));
        contIdx++;
      }
    }

      /*
       * Overwrite the "merged" list with the new stuff.
       */
    pMergedInfoRef.set(pNewSorted);

//  #if 0       // for Vector, rather than SortedVector
//      int i, j;
//      for (i = pContents.size() -1; i >= 0; i--) {
//          boolean add = true;
//
//          for (j = pMergedInfo.size() -1; j >= 0; j--) {
//              /* case-sensitive comparisons, to behave like UNIX fs */
//              if (strcmp(pContents.itemAt(i).mFileName,
//                         pMergedInfo.itemAt(j).mFileName) == 0)
//              {
//                  /* match, don't add this entry */
//                  add = false;
//                  break;
//              }
//          }
//
//          if (add)
//              pMergedInfo.add(pContents.itemAt(i));
//      }
//  #endif
  }
void mergeInfoLocked ( Ref < SortedVector < AssetDir . FileInfo > > pMergedInfoRef , final SortedVector < AssetDir . FileInfo > pContents ) { /*
       * Merge what we found in this directory with what we found in
       * other places.
       *
       * Two basic approaches:
       * (1) Create a new array that holds the unique values of the two
       *     arrays.
       * (2) Take the elements from pContents and shove them into pMergedInfo.
       *
       * Because these are vectors of complex objects, moving elements around
       * inside the vector requires finalructing new objects and allocating
       * storage for members.  With approach #1, we're always adding to the
       * end, whereas with #2 we could be inserting multiple elements at the
       * front of the vector.  Approach #1 requires a full copy of the
       * contents of pMergedInfo, but approach #2 requires the same copy for
       * every insertion at the front of pMergedInfo.
       *
       * (We should probably use a SortedVector interface that allows us to
       * just stuff items in, trusting us to maintain the sort order.)
       */ SortedVector < AssetDir . FileInfo > pNewSorted ; int mergeMax , contMax ; int mergeIdx , contIdx ; SortedVector < AssetDir . FileInfo > pMergedInfo = pMergedInfoRef . get ( ) ; pNewSorted = new SortedVector <> ( ) ; mergeMax = pMergedInfo . size ( ) ; contMax = pContents . size ( ) ; mergeIdx = contIdx = 0 ; while ( mergeIdx < mergeMax || contIdx < contMax ) { if ( mergeIdx == mergeMax ) { /* hit end of "merge" list, copy rest of "contents" */ pNewSorted . add ( pContents . itemAt ( contIdx ) ) ; contIdx ++ ; } else if ( contIdx == contMax ) { /* hit end of "cont" list, copy rest of "merge" */ pNewSorted . add ( pMergedInfo . itemAt ( mergeIdx ) ) ; mergeIdx ++ ; } else if ( pMergedInfo . itemAt ( mergeIdx ) == pContents . itemAt ( contIdx ) ) { /* items are identical, add newer and advance both indices */ pNewSorted . add ( pContents . itemAt ( contIdx ) ) ; mergeIdx ++ ; contIdx ++ ; } else if ( pMergedInfo . itemAt ( mergeIdx ) . isLessThan ( pContents . itemAt ( contIdx ) ) ) { /* "merge" is lower, add that one */ pNewSorted . add ( pMergedInfo . itemAt ( mergeIdx ) ) ; mergeIdx ++ ; } else { /* "cont" is lower, add that one */ assert ( pContents . itemAt ( contIdx ) . isLessThan ( pMergedInfo . itemAt ( mergeIdx ) ) ) ; pNewSorted . add ( pContents . itemAt ( contIdx ) ) ; contIdx ++ ; } } /*
       * Overwrite the "merged" list with the new stuff.
       */ pMergedInfoRef . set ( pNewSorted ) ; //  #if 0       // for Vector, rather than SortedVector //      int i, j; //      for (i = pContents.size() -1; i >= 0; i--) { //          boolean add = true; // //          for (j = pMergedInfo.size() -1; j >= 0; j--) { //              /* case-sensitive comparisons, to behave like UNIX fs */ //              if (strcmp(pContents.itemAt(i).mFileName, //                         pMergedInfo.itemAt(j).mFileName) == 0) //              { //                  /* match, don't add this entry */ //                  add = false; //                  break; //              } //          } // //          if (add) //              pMergedInfo.add(pContents.itemAt(i)); //      } //  #endif }
/*
Merge two vectors of FileInfo.

The merged contents will be stuffed into *pMergedInfo.

If an entry for a file exists in both "pMergedInfo" and "pContents",
we use the newer "pContents" entry.
/ * Merge two vectors of FileInfo .