/* IRedisList implementations
554974
@Override public String lindex(final String key, long index) throws WrongTypeException {
        return redisMock.lindex(key, index);
    }
179846
private void _serializeList(String name, List list, StringBuilder sb, Set<Object> done) throws ConverterException {

	if (useShortcuts) sb.append("[];");
	else sb.append("new Array();");

	ListIterator it = list.listIterator();
	int index = -1;
	while (it.hasNext()) {
	    // if(index!=-1)sb.append(",");
	    index = it.nextIndex();
	    sb.append(name + "[" + index + "]=");
	    _serialize(name + "[" + index + "]", it.next(), sb, done);
	    // sb.append(";");
	}
    }
684999
function _makeSmallData(&$raList)
    {
        $sRes = '';
        $FILE = $this->_FILEH_;
        $iSmBlk = 0;
   
        for ($i = 0; $i < count($raList); $i++) {
            // Make SBD, small data string
            if ($raList[$i]->Type == OLE_PPS_TYPE_FILE) {
                if ($raList[$i]->Size <= 0) {
                    continue;
                }
                if ($raList[$i]->Size < OLE_DATA_SIZE_SMALL) {
                    $iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
                                  + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
                    // Add to SBD
                    for ($j = 0; $j < ($iSmbCnt-1); $j++) {
                        fwrite($FILE, pack("V", $j+$iSmBlk+1));
                    }
                    fwrite($FILE, pack("V", -2));
                   
                    // Add to Data String(this will be written for RootEntry)
                    if ($raList[$i]->_PPS_FILE) {
                        fseek($raList[$i]->_PPS_FILE, 0); // To The Top
                        while ($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
                            $sRes .= $sBuff;
                        }
                    } else {
                        $sRes .= $raList[$i]->_data;
                    }
                    if ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) {
                        for ($j = 0; $j < ($this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)); $j++) {
                            $sRes .= "\x00";
                        }
                    }
                    // Set for PPS
                    $raList[$i]->_StartBlock = $iSmBlk;
                    $iSmBlk += $iSmbCnt;
                }
            }
        }
        $iSbCnt = floor($this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE);
        if ($iSmBlk % $iSbCnt) {
            for ($i = 0; $i < ($iSbCnt - ($iSmBlk % $iSbCnt)); $i++) {
                fwrite($FILE, pack("V", -1));
            }
        }
        return $sRes;
    }
364670
@Deprecated
  public SoyEasyList newEasyListFromList(SoyList list) {
    EasyListImpl result = new EasyListImpl();
    for (SoyValueProvider provider : list.asJavaList()) {
      result.add(provider);
    }
    return result;
  }
746855
function getFileList($rdir, $showHidden = false)
    {
        $filelist = '';
        if ($handle = opendir($rdir))
        {
            while (false !== ($file = readdir($handle)))
            {
                if ($file == '.' or $file == '..')
                {
                    continue;
                }

                if ($file{0} == "." and !$showHidden)
                {
                    continue;
                }

                $stats = stat($rdir . "/" . $file);
                if (is_dir($rdir . "/" . $file)) $mode = "d"; else $mode = "-";
                $moded = sprintf("%o", ($stats['mode'] & 000777));
                $mode1 = substr($moded, 0, 1);
                $mode2 = substr($moded, 1, 1);
                $mode3 = substr($moded, 2, 1);
                switch ($mode1) {
                    case "0":
                        $mode .= "---";
                        break;
                    case "1":
                        $mode .= "--x";
                        break;
                    case "2":
                        $mode .= "-w-";
                        break;
                    case "3":
                        $mode .= "-wx";
                        break;
                    case "4":
                        $mode .= "r--";
                        break;
                    case "5":
                        $mode .= "r-x";
                        break;
                    case "6":
                        $mode .= "rw-";
                        break;
                    case "7":
                        $mode .= "rwx";
                        break;
                }
                switch ($mode2) {
                    case "0":
                        $mode .= "---";
                        break;
                    case "1":
                        $mode .= "--x";
                        break;
                    case "2":
                        $mode .= "-w-";
                        break;
                    case "3":
                        $mode .= "-wx";
                        break;
                    case "4":
                        $mode .= "r--";
                        break;
                    case "5":
                        $mode .= "r-x";
                        break;
                    case "6":
                        $mode .= "rw-";
                        break;
                    case "7":
                        $mode .= "rwx";
                        break;
                }
                switch ($mode3) {
                    case "0":
                        $mode .= "---";
                        break;
                    case "1":
                        $mode .= "--x";
                        break;
                    case "2":
                        $mode .= "-w-";
                        break;
                    case "3":
                        $mode .= "-wx";
                        break;
                    case "4":
                        $mode .= "r--";
                        break;
                    case "5":
                        $mode .= "r-x";
                        break;
                    case "6":
                        $mode .= "rw-";
                        break;
                    case "7":
                        $mode .= "rwx";
                        break;
                }
                $uidfill = "";
                for ($i = strlen($stats['uid']); $i < 5; $i++) $uidfill .= " ";
                $gidfill = "";
                for ($i = strlen($stats['gid']); $i < 5; $i++) $gidfill .= " ";
                $sizefill = "";
                for ($i = strlen($stats['size']); $i < 11; $i++) $sizefill .= " ";
                $nlinkfill = "";
                for ($i = strlen($stats['nlink']); $i < 5; $i++) $nlinkfill .= " ";
                $mtime = date("M d H:i", $stats['mtime']);
                $filelist .= $mode . $nlinkfill . $stats['nlink'] . " " . $stats['uid'] . $uidfill . $stats['gid'] . $gidfill . $sizefill . $stats['size'] . " " . $mtime . " " . $file . "\r\n";
            }
            closedir($handle);
        }
        return $filelist;
    }
200775
@Override
    public void getUserLists(final long listOwnerUserId) {
        getDispatcher().invokeLater(new AsyncTask(USER_LISTS, listeners) {
            @Override
            public void invoke(List<TwitterListener> listeners) throws TwitterException {
                ResponseList<UserList> lists = twitter.getUserLists(listOwnerUserId);
                for (TwitterListener listener : listeners) {
                    try {
                        listener.gotUserLists(lists);
                    } catch (Exception e) {
                        logger.warn("Exception at getUserLists", e);
                    }
                }
            }
        });
    }
1357152
@Override
    public List<org.fcrepo.server.types.gen.ObjectMethodsDef> listMethods(String pid,
                                                                               String asOfDateTime) {
        MessageContext ctx = context.getMessageContext();
        Context context = ReadOnlyContext.getSoapContext(ctx);
        assertInitialized();
        try {
            org.fcrepo.server.storage.types.ObjectMethodsDef[] objectMethodDefs =
                    m_access.listMethods(context, pid, DateUtility
                            .parseDateOrNull(asOfDateTime));
            return TypeUtility
                    .convertObjectMethodsDefArrayToGenObjectMethodsDefList(objectMethodDefs);
        } catch (Throwable th) {
            LOG.error("Error listing methods", th);
            throw CXFUtility.getFault(th);
        }
    }
785203
def findDuplicateRecordIDs(  fnames, fids, dbid = @dbid, ignoreCase = true )
      verifyFieldList( fnames, fids, dbid )
      duplicates = {}
      if @fids
         cslist = @fids.join( "." )
         ridFields = lookupFieldsByType( "recordid" )
         if ridFields and ridFields.last
           cslist << "."
           recordidFid = ridFields.last.attributes["id"]
           cslist << recordidFid
           valuesUsed = {}
            doQuery( @dbid, nil, nil, nil, cslist ) { |record|
               next unless record.is_a?( REXML::Element) and record.name == "record"
               recordID = ""
               recordValues = []
               record.each { |f|
                  if f.is_a?( REXML::Element) and f.name == "f" and  f.has_text?
                     if recordidFid == f.attributes["id"]
                        recordID = f.text
                     else
                        recordValues << f.text
                     end
                  end
              }
              if not valuesUsed[ recordValues ]
                 valuesUsed[ recordValues ] = []
              end
              valuesUsed[ recordValues ] << recordID
            }

            valuesUsed.each{ |valueArray, recordArray|
               if recordArray.length > 1
                 duplicates[ valueArray ] = recordArray
               end
            }
         end
      end
      if block_given?
         duplicates.each{ |duplicate| yield duplicate }
      else
         duplicates
      end
   end
599651
private <T> boolean addToListInternal(Collection<T> list, T value) {
        if (!list.contains(value)) {
            list.add(value);
            isModified = true;
            return true;
        } else {
            return false;
        }
    }
820383
private void createDetectedList(int which, List<PointIndex2D_F64> pixels) {
		detected2D3D.clear();
		List<Point2D3D> all = getControl3D(which);
		for (int i = 0; i < pixels.size(); i++) {
			PointIndex2D_F64 a = pixels.get(i);
			Point2D3D b = all.get(i);

			pixelToNorm.compute(a.x,a.y, b.observation);
			detected2D3D.add( b );
		}
	}
683671
protected void addToSelectList(
		List<SqlNode> list,
		Set<String> aliases,
		List<Map.Entry<String, RelDataType>> fieldList,
		SqlNode exp,
		SqlValidatorScope scope,
		final boolean includeSystemVars) {
		String alias = SqlValidatorUtil.getAlias(exp, -1);
		String uniqueAlias =
			SqlValidatorUtil.uniquify(
				alias, aliases, SqlValidatorUtil.EXPR_SUGGESTER);
		if (!alias.equals(uniqueAlias)) {
			exp = SqlValidatorUtil.addAlias(exp, uniqueAlias);
		}
		fieldList.add(Pair.of(uniqueAlias, deriveType(scope, exp)));
		list.add(exp);
	}
894820
def getidfobjectlist(idf):
    """"""
    idfobjects = idf.idfobjects  
    # idfobjlst = [idfobjects[key] for key in idfobjects if idfobjects[key]]
    idfobjlst = [idfobjects[key] for key in idf.model.dtls if idfobjects[key]]
        # `for key in idf.model.dtls` maintains the order
        # `for key in idfobjects` does not have order
    idfobjlst = itertools.chain.from_iterable(idfobjlst)
    idfobjlst = list(idfobjlst)
    return idfobjlst
1067501
public synchronized FieldList makeRowCurrent(int iRowIndex, boolean bLockRecord)
    {
        FieldList fieldList = null;
        if (m_table == null)
            return null;
        if (iRowIndex == -1)
        {
            this.setCurrentRow(iRowIndex);     // Invalidate the current row
            if (bLockRecord)
                m_iCurrentLockedRowIndex = iRowIndex;
            return null;
        }
        try   {
            if ((iRowIndex == this.getCurrentRow()) && (!bLockRecord))
                fieldList = m_table.getRecord();   // Already current record
            else
            {
                if ((m_iLastRecord == RECORD_UNKNOWN) || (iRowIndex <= m_iLastRecord))
                {
                    fieldList = (FieldList)m_table.get(iRowIndex);  // Read this record
                    if ((fieldList == null) || (fieldList.getEditMode() == Constants.EDIT_ADD) || (fieldList.getEditMode() == Constants.EDIT_NONE))
                        if (m_iCurrentLockedRowIndex == iRowIndex)
                    {
                        m_iCurrentLockedRowIndex = -1;
                        m_buffCurrentLockedData = null; // This record was deleted, clear the buffer!                 
                    }
                    if (bLockRecord)
                        if (fieldList != null)
                            if (fieldList.getEditMode() == Constants.EDIT_CURRENT)
                            {
                                if (m_table.edit() == Constants.NORMAL_RETURN)
                                    fieldList = m_table.getRecord();    // A physical read may have changed the record.
                            }
                }
                else
                {   // Past the EOF, just supply a blank record
                    m_table.addNew();
                    fieldList = m_table.getRecord();
                }
                int iOldRowCount = this.getRowCount(true);
                if (fieldList != null) if (m_iLastRecord == RECORD_UNKNOWN)
                {
                    this.checkRowValue(iRowIndex);
                    if (this.getRowCount(true) > iOldRowCount)
                        this.fireTableRowsInserted(iOldRowCount, this.getRowCount(true) - 1);
                    else if (this.getRowCount(true) < iOldRowCount)
                        this.fireTableRowsDeleted(iOldRowCount, this.getRowCount(true) - 1);
                }
                if (fieldList == null)
                { // Got to end of file!
                    if ((m_iLastRecord == RECORD_UNKNOWN) && (iRowIndex > m_iLargestValidRecord))
                    {
                        if (iRowIndex == m_iLargestValidRecord + 1)
                        {
                            m_iLastRecord = iRowIndex - 1;  // Now I know the actual EOF
                        }
                        else if (iRowIndex > m_iLargestValidRecord + 1)
                        {
                            int iEOF = m_table.size();
                            if (iEOF != -1)
                            {
                                m_iLastRecord = iEOF - 1;
                                iRowIndex = m_iLastRecord + 1;
                            }
                            else
                            {   // Okay, the EOF is somewhere between m_iLargestValidRecord+1 and iRowIndex.. find it!
                                int iTargetIndex = (m_iLargestValidRecord + 1 + iRowIndex) / 2;
                                while (iTargetIndex > m_iLargestValidRecord + 1)
                                {
                                    fieldList = (FieldList)m_table.get(iTargetIndex);  // Read this record
                                    if (fieldList != null)
                                        m_iLargestValidRecord = iTargetIndex;
                                    else
                                        iRowIndex = iTargetIndex;
                                    iTargetIndex = (m_iLargestValidRecord + 1 + iRowIndex) / 2;
                                }
                                m_iLastRecord = m_iLargestValidRecord;
                                iRowIndex = m_iLastRecord + 1;
                            }
                        }
                        this.setRowCount(iRowIndex);        // new EOF
                        if (iOldRowCount > this.getRowCount(true))
                            this.fireTableRowsDeleted(this.getRowCount(true), iOldRowCount - 1);
                        if (this.getSelectedRow() != -1)
                        {
                            if (this.getSelectedRow() > this.getRowCount())
                            {
                                this.makeRowCurrent(this.getRowCount() - 1, false);
//                                this.selectionChanged(this, this.getRowCount() - 1, this.getRowCount() -1 , DBConstants.SELECT_TYPE);
                            }
                        }
                    }
                    m_table.addNew();
                    fieldList = m_table.getRecord();
                }
            }
            if ((m_iCurrentLockedRowIndex != -1) && (m_iCurrentLockedRowIndex == iRowIndex)
                && (m_buffCurrentLockedData != null))
                    this.restoreCurrentRecord(fieldList); // Restore current edit record
        } catch (Exception ex)  {
            if (!this.displayError(ex, null))
                ex.printStackTrace();
        }
        this.setCurrentRow(iRowIndex);     // Successfully read
        return fieldList;
    }
1270036
private <Q extends IBaseExtension<?, ?>> List<IBaseExtension<?, ?>> toBaseExtensionList(final List<Q> theList) {
		List<IBaseExtension<?, ?>> retVal = new ArrayList<IBaseExtension<?, ?>>(theList.size());
		retVal.addAll(theList);
		return retVal;
	}
371673
@Override
  public void replace(List list, String resourceVersion) {
    lock.writeLock().lock();
    try {
      Set<String> keys = new HashSet<>();
      for (Object obj : list) {
        String key = this.keyOf(obj);
        keys.add(key);
        this.queueActionLocked(DeltaType.Sync, obj);
      }

      if (this.knownObjects == null) {
        for (Map.Entry<String, Deque<MutablePair<DeltaType, Object>>> entry :
            this.items.entrySet()) {
          if (keys.contains(entry.getKey())) {
            continue;
          }

          Object deletedObj = null;
          MutablePair<DeltaType, Object> delta = entry.getValue().peekLast(); // get newest
          if (delta != null) {
            deletedObj = delta.getRight();
          }
          this.queueActionLocked(
              DeltaType.Deleted, new DeletedFinalStateUnknown(entry.getKey(), deletedObj));
        }

        if (!this.populated) {
          this.populated = true;
          this.initialPopulationCount = list.size();
        }
        return;
      }

      // Detect deletions not already in the queue.
      List<String> knownKeys = this.knownObjects.listKeys();
      int queueDeletion = 0;
      for (String knownKey : knownKeys) {
        if (keys.contains(knownKey)) {
          continue;
        }

        Object deletedObj = this.knownObjects.getByKey(knownKey);
        if (deletedObj == null) {
          log.warn(
              "Key {} does not exist in known objects store, placing DeleteFinalStateUnknown marker without object",
              knownKey);
        }
        queueDeletion++;
        this.queueActionLocked(
            DeltaType.Deleted, new DeletedFinalStateUnknown<>(knownKey, deletedObj));
      }

      if (!this.populated) {
        this.populated = true;
        this.initialPopulationCount = list.size() + queueDeletion;
      }
    } finally {
      lock.writeLock().unlock();
    }
  }
1276445
public static <T> List<T> filter(List<T> list, Editor<T> editor) {
		if (null == list || null == editor) {
			return list;
		}

		final List<T> list2 = (list instanceof LinkedList) ? new LinkedList<T>() : new ArrayList<T>(list.size());
		T modified;
		for (T t : list) {
			modified = editor.edit(t);
			if (null != modified) {
				list2.add(modified);
			}
		}
		return list2;
	}
1121737
NamedList<Object> getNamedList(boolean showDebugInfo) throws IOException {
    if (dataCollector.getCollectorType()
        .equals(DataCollector.COLLECTOR_TYPE_LIST)) {
      SimpleOrderedMap<Object> mtasResponseList = new SimpleOrderedMap<>();
      // functions
      Map<String, SimpleOrderedMap<Object>> functionList = new HashMap<>();
      if (functionData != null && functionData.containsKey(dataCollector)) {
        HashMap<String, MtasSolrMtasResult> functionDataItem = functionData
            .get(dataCollector);
        for (Entry<String, MtasSolrMtasResult> entry : functionDataItem
            .entrySet()) {
          MtasSolrMtasResult functionResult = entry.getValue();
          if (functionResult.dataCollector.getCollectorType()
              .equals(DataCollector.COLLECTOR_TYPE_LIST)) {
            NamedList<Object> functionNamedList = functionResult
                .getNamedList(showDebugInfo);
            for (int i = 0; i < functionNamedList.size(); i++) {
              if (functionList.containsKey(functionNamedList.getName(i))) {
                SimpleOrderedMap<Object> tmpMap = functionList
                    .get(functionNamedList.getName(i));
                tmpMap.add(entry.getKey(), functionNamedList.getVal(i));
              } else {
                SimpleOrderedMap<Object> tmpMap = new SimpleOrderedMap<>();
                tmpMap.add(entry.getKey(), functionNamedList.getVal(i));
                functionList.put(functionNamedList.getName(i), tmpMap);
              }
            }
          } else {
            throw new IOException("unexpected function collectorType "
                + functionResult.dataCollector.getCollectorType());
          }
        }
      }
      // main result
      Map<String, ?> dataList = dataCollector.getResult().getList();
      for (Entry<String, ?> entry : dataList.entrySet()) {
        SimpleOrderedMap<Object> mtasResponseListItem = new SimpleOrderedMap<>();
        MtasDataItem<?, ?> dataItem = (MtasDataItem<?, ?>) entry.getValue();
        if (this.distances != null && !this.distances.isEmpty()) {
          SimpleOrderedMap<Object> mtasResponseListItemDistance = new SimpleOrderedMap<>();
          for (SubComponentDistance item : this.distances) {
            mtasResponseListItemDistance.add(item.key,
                item.getDistance().compute(entry.getKey()));
          }
          mtasResponseListItem.add(Distance.NAME, mtasResponseListItemDistance);
        }
        mtasResponseListItem.addAll(dataItem.rewrite(showDebugInfo));
        if (functionList.containsKey(entry.getKey())) {
          mtasResponseListItem.add("functions",
              functionList.get(entry.getKey()));
        }
        if ((subDataType != null) && (dataItem.getSub() != null)) {
          MtasSolrMtasResult css = new MtasSolrMtasResult(dataItem.getSub(),
              subDataType, subStatsType, subStatsItems, subDistances,
              subSortType, subSortDirection, subStart, subNumber, functionData);
          if (dataItem.getSub().getCollectorType()
              .equals(DataCollector.COLLECTOR_TYPE_LIST)) {
            if (css.dataCollector.withTotal()) {
              mtasResponseListItem.add(
                  DataCollector.COLLECTOR_TYPE_LIST + "Total",
                  css.dataCollector.getSize());
            }
            mtasResponseListItem.add(DataCollector.COLLECTOR_TYPE_LIST,
                css.getNamedList(showDebugInfo));
          } else if (dataItem.getSub().getCollectorType()
              .equals(DataCollector.COLLECTOR_TYPE_DATA)) {
            mtasResponseListItem.add(DataCollector.COLLECTOR_TYPE_DATA,
                css.getData(showDebugInfo));
          }
        }
        mtasResponseList.add(entry.getKey(), mtasResponseListItem);
      }
      return mtasResponseList;
    } else {
      throw new IOException(
          "only allowed for " + DataCollector.COLLECTOR_TYPE_LIST);
    }
  }