for turning an array into a pagable set (for use with lucene, rss, etc)
766273
public function limitResultsToPage($results = array())
    {
        $posIndexedResults = array();
        foreach ($results as $ignoredKey => $result) {
            $posIndexedResults[] = $result;
        }
        $limitedResults = array();
        $start = $this->result_offset;
        $end = $this->result_offset + $this->page_size;
        //echo 	$start.' '.	$end.'<Br>';
        for ($pos = $start; $pos < $end; ++$pos) {
            if (!$posIndexedResults[$pos]) {
                continue;
            }
            $limitedResults[] = $posIndexedResults[$pos];
        }

        return $limitedResults;
    }
1268225
function toArray(iterable) {
    // kinda optimisations
    if (isArray(iterable)) {
        return iterable.slice();
    }
    if (typeof iterable === 'string') {
        return iterable.split('');
    }

    var iter = ensureIter(iterable);
    var result = [];
    var next = iter.next();
    while (!next.done) {
        result.push(next.value);
        next = iter.next();
    }
    return result;
}
616238
private static void enlargeTables(float[][] data, int[][] rowIndex, int cols, int currentRow, int currentCol) {
        while (data[currentRow].length < currentCol + cols) {
            if(data[currentRow].length == SPARSE_MATRIX_DIM) {
                currentCol = 0;
                cols -= (data[currentRow].length - currentCol);
                currentRow++;
                data[currentRow] = malloc4f(ALLOCATED_ARRAY_LEN);
                rowIndex[currentRow] = malloc4(ALLOCATED_ARRAY_LEN);
            } else {
                int newLen = (int) Math.min((long) data[currentRow].length << 1L, (long) SPARSE_MATRIX_DIM);
                data[currentRow] = Arrays.copyOf(data[currentRow], newLen);
                rowIndex[currentRow] = Arrays.copyOf(rowIndex[currentRow], newLen);
            }
        }
    }
643406
static Iterable<Tag> toIterable(String[] tags) {
    if (tags.length % 2 == 1) {
      throw new IllegalArgumentException("size must be even, it is a set of key=value pairs");
    }
    ArrayList<Tag> ts = new ArrayList<>(tags.length / 2);
    for (int i = 0; i < tags.length; i += 2) {
      ts.add(new BasicTag(tags[i], tags[i + 1]));
    }
    return ts;
  }
1159010
static function simpleXmlToArrayHelper(&$res, &$key, &$value, &$children)
  {
    if (isset($res[$key])) {
      if (is_string($res[$key]) || (is_array($res[$key]) && is_assoc($res[$key]))) {
        $res[$key] = array($res[$key]);
      }
      $res[$key][] = CPS_Response::simpleXmlToArray($value);
    } else {
      $res[$key] = CPS_Response::simpleXmlToArray($value);
    }
    $children = true;
  }
1144836
def api_get_collection(path, collection, *args)
      Enumerator.new do |enum|
        args[0] = {} unless args[0]
        page_size = (args[0].delete(:page_size) { 100 }).to_i
        page_number = (args[0].delete(:page_number) { 1 }).to_i

        loop do
          uri = URI::HTTP.build(path: "/#{path}", query: URI.encode_www_form(pageSize: page_size, pageNumber: page_number)).request_uri

          res = api_get(uri, *args)
          raise TableauError, res if res.code.to_s != '200'

          # ensure the result is an array because it will not be an array if there is only one element
          [collection.split('.').reduce(res['tsResponse']) { |acc, elem| acc && acc[elem] }].flatten.compact.each do |obj|
            enum.yield obj
          end

          break if res['tsResponse']['pagination'].nil?
          break if page_number >= (res['tsResponse']['pagination']['totalAvailable'].to_i / page_size.to_f).ceil

          page_number += 1
        end
      end
    end
747162
public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) {
        if ($index !== false) $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array();
        $mq = $mq_fix && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc();

        $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema);
        $ret = array();
        foreach ($allowed as $key) {
            list($ns, $directive) = $key;
            $skey = "$ns.$directive";
            if (!empty($array["Null_$skey"])) {
                $ret[$ns][$directive] = null;
                continue;
            }
            if (!isset($array[$skey])) continue;
            $value = $mq ? stripslashes($array[$skey]) : $array[$skey];
            $ret[$ns][$directive] = $value;
        }
        return $ret;
    }
999554
def slice(self, start=0, end=0):
        """"""
        tmp = Gauged.map_new()
        if tmp is None:
            raise MemoryError
        if not Gauged.map_concat(tmp, self.ptr, start, end, 0):
            Gauged.map_free(tmp)  # pragma: no cover
            raise MemoryError
        return SparseMap(tmp)
152005
function listToArray ( list, opts ) {
	const length = list.getLength();
	const data = [];
	for ( let i = 0; i < length; i++ ) {
		const value = getJsonValueFromSassValue(list.getValue(i), opts);
		data.push(value);
	}
	return data;
}
933764
private void _serializeArray(PageContext pc, Set test, Array array, StringBuilder sb, boolean serializeQueryByColumns, Set<Object> done) throws ConverterException {
	_serializeList(pc, test, array.toList(), sb, serializeQueryByColumns, done);
    }
131769
function arrayMap$1(array, iteratee) {
  var index = -1,
      length = array == null ? 0 : array.length,
      result = Array(length);

  while (++index < length) {
    result[index] = iteratee(array[index], index, array);
  }
  return result;
}
1050751
function parseArray(array) {
  const templates = array.map(parse);
  const templateParameters = templates.reduce(
    (parameters, template) => parameters.concat(template.parameters),
    []
  );
  const templateFn = context => templates.map(template => template(context));

  return Template(templateFn, templateParameters);
}
900621
public function simpleRendeArray()
    {
        $array = [];
        $count = $this->paginator->getCount();
        $url = $this->path;
        $current = $this->paginator->getCurrentPage();

        // create appends string
        $appends = $this->createAppendString($this->paginator->getAppends());

        // create fragments string
        $fragments = $this->createFragmentsString($this->paginator->getFragments());


        if ($count < $this->paginator->getPerPage()) {
            $limit = 1;
        } else {
            $limit = ceil($count / $this->paginator->getPerPage());
        }


        if ($this->isAvaibleCurrentPage($current) && $current > 1) {

            $previous = $current - 1;
            $array[] = $this->buildChieldString('Previous', $this->buildFullChieldStrind($url, $appends), $this->pageName, $fragments, $previous);

        }

        if ($this->isAvaibleCurrentPage($current) && $current < $limit) {
            $next = $current + 1;

            $array[] = $this->buildChieldString('Next', $this->buildFullChieldStrind($url, $appends), $this->pageName, $fragments, $next);
        }

        return $array;
    }
1006428
function iteratorToArray(iterator) {
        var data,
            result = [];

        while (!(data = iterator.next()).done) {
            result.push(data.value);
        }
        return result;
    }
1212744
function arrayify(urls) {
  var tmp = Array.isArray(urls) ? urls : [urls];
  return tmp.filter(Boolean);
}
1241305
function arraySlice (array, startIndex, endIndex) {
  var result = []
  if (array) {
    for (startIndex = startIndex || 0, endIndex = endIndex || array.length; startIndex < endIndex; startIndex++) {
      result.push(array[startIndex])
    }
  }
  return result
}
514038
private P byteArrayToPage(byte[] array) {
    try {
      ByteArrayInputStream bais = new ByteArrayInputStream(array);
      ObjectInputStream ois = new ObjectInputStream(bais);
      int type = ois.readInt();
      if(type == EMPTY_PAGE) {
        return null;
      }
      else if(type == FILLED_PAGE) {
        P page;
        try {
          page = pageclass.newInstance();
          page.readExternal(ois);
        }
        catch(InstantiationException|IllegalAccessException|ClassNotFoundException e) {
          throw new AbortException("Error instanciating an index page", e);
        }
        return page;
      }
      else {
        throw new IllegalArgumentException("Unknown type: " + type);
      }
    }
    catch(IOException e) {
      throw new AbortException("IO Error in page file", e);
    }
  }