// Constructs a List, copying the contents of the given collection. The // size and capacity of the new list will both be equal to the size of the // given collection. // public List(System.Collections.Generic.IEnumerable <T> collection) { if (collection == null) { throw new Exception(); } System.Collections.Generic.ICollection <T> c = collection as System.Collections.Generic.ICollection <T>; if (c != null) { int count = c.Count; _items = new T[count]; c.CopyTo(_items, 0); _size = count; } else { _size = 0; _items = new T[_defaultCapacity]; using (System.Collections.Generic.IEnumerator <T> en = collection.GetEnumerator()) { while (en.MoveNext()) { Add(en.Current); } } } }
ToArray <T>(System.Collections.Generic.ICollection <T> collection) { var result = new T[collection.Count]; collection.CopyTo(result, 0); return(result); }
private void getDeviceTag(object sender, EventArgs e) { TextView tagsTextView = FindViewById <TextView>(Resource.Id.tags_text); System.Collections.Generic.ICollection <string> tags = appoxeeInstance.Tags; string[] strArray = new string[tags.Count]; tags.CopyTo(strArray, 0); string tagValues = string.Join(",", strArray); tagsTextView.Text = tagValues; }
/// <summary> Return a query that will return docs like the passed file. /// /// </summary> /// <returns> a query that will return docs like the passed file. /// </returns> public Query Like(System.IO.FileInfo f) { if (fieldNames == null) { // gather list of valid fields from lucene System.Collections.Generic.ICollection <string> fields = ir.GetFieldNames(IndexReader.FieldOption.INDEXED); fieldNames = new string[fields.Count]; fields.CopyTo(fieldNames, 0); } return(Like(new System.IO.StreamReader(f.FullName, System.Text.Encoding.Default))); }
/// <summary> Return a query that will return docs like the passed lucene document ID. /// /// </summary> /// <param name="docNum">the documentID of the lucene doc to generate the 'More Like This" query for. /// </param> /// <returns> a query that will return docs like the passed lucene document ID. /// </returns> public Query Like(int docNum) { if (fieldNames == null) { // gather list of valid fields from lucene System.Collections.Generic.ICollection <string> fields = ir.GetFieldNames(IndexReader.FieldOption.INDEXED); fieldNames = new string[fields.Count]; fields.CopyTo(fieldNames, 0); } return(CreateQuery(RetrieveTerms(docNum))); }
// Inserts the elements of the given collection at a given index. If // required, the capacity of the list is increased to twice the previous // capacity or the new size, whichever is larger. Ranges may be added // to the end of the list by setting index to the List's size. // public void InsertRange(int index, System.Collections.Generic.IEnumerable <T> collection) { if (collection == null) { throw new Exception(); } if ((uint)index > (uint)_size) { throw new Exception(); } System.Collections.Generic.ICollection <T> c = collection as System.Collections.Generic.ICollection <T>; if (c != null) { // if collection is System.Collections.Generic.ICollection<T> int count = c.Count; if (count > 0) { EnsureCapacity(_size + count); if (index < _size) { Array.Copy(_items, index, _items, index + count, _size - index); } // If we're inserting a List into itself, we want to be able to deal with that. if (this == c) { // Copy first part of _items to insert location Array.Copy(_items, 0, _items, index, index); // Copy last part of _items back to inserted location Array.Copy(_items, index + count, _items, index * 2, _size - index); } else { T[] itemsToInsert = new T[count]; c.CopyTo(itemsToInsert, 0); itemsToInsert.CopyTo(_items, index); } _size += count; } } else { using (System.Collections.Generic.IEnumerator <T> en = collection.GetEnumerator()) { while (en.MoveNext()) { Insert(index++, en.Current); } } } _version++; }