MCTS-536 - Cap 4 - Colecoes e Generics
Autor: Manual de fotografia | Publicado: 2010-09-16T06:52:00-07:00

o&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SortedListo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ë igual ao dictionary, porém ordenadoo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Propriedades&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; §&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; capacity: Número de itens alocados atualmente na lista§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; containsKey: Verifica a existência de uma chave§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; containsValue: Verifica a existência de uma valor§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getByIndex: Pega os valores através do índice§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getKey: Retorna a chave do índice relativo§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getKeyList: Retorna a Lista ordenada de chaves§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getValueList: Retorna a Lista de Valores§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; indexOfKey: Retorna o Índice da chave§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; índexOfValue: Retorna o índice da primeira ocorrência daquele valor.§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; removeAt: Retorna um valor específico da coleção através de um índice§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setByIndex: Troca o valor no índice§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; trimToSize: Libera o espaço não utilizadoo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Specillized Dictionarieso&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ListDictionary: Útil para pequenas coleções pois otimiza a performanceo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hybrid Dictionary: É uma ListDictionary que quando necessário cresce para uma HashTableo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OrderedTable: É uma HashTable que tem acesso pelo índiceo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Specillized Collections (System.collection.Speciallized)o&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Coleções para se trabalhar com bits§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BitArray:a.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Redimensionável, porém não dinamicamenteb.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Não suporta add, remove, so aceita os valores true ou falsec.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Em sua criação todos os valores são falsosd.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Acesso aos valores pelo índicee.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Opera operações and, or, xor entre colecoe do mesmo tipo, colocando seu resultado em outro array§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BitArray32:f.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ideal para se trabalhar com muitos componentesg.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Guarda Tudo num inteiro de 32 bitsh.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data: Retorna o valor desse inteiroi.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; createMask: Cria um inteiro deste tipoj.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bitPacking: Agrupa vários números no valor de um inteiroo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Coleções para se trabalhar com strings§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Denominado StringCollection, nada mais é que que um ArrayList de strings§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Quando adicionados itens não strings dá erro§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Não necessita a transformação para string§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringDictionary: É uma HashTable para strings, tanto para os indices quanto para os valores.§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CollectionUtil: É uma biblioteca do framework, que tem entre seus métodos, o createInsensitiveHashTable, e o createCaseInsensitiveSortedList, que tratam caixas altas e baixas.§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringComparer: Compara as strings independente da informação culturalo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;NameValueCollection (System.collection.Specillized) NameValueCollection): PArece a String Dictionary, mas é possível de se acessar pelo indice e de se ter chaves com mais de um valor, adicionadas utilizando o commando add.o&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GenericsCollection§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Generics: São tipos criados para receberem como parâmetro qualquer tipo. Esse parâmetro e declarado da forma &lt;varariável&gt;, e na hora de instanciar um destes objetos é necessário informar o tipo.§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Todas as coleções tem seu equivalente me genericsa.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ArrayList – List &lt;&gt;b.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Queue – Queue&lt;&gt;c.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stack – Stack&lt;&gt;d.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HashTable-Dictionary&lt;&gt;e.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SortedList – SortedList&lt;&gt;f.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ListDictionary – Dictionary&lt;&gt;g.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HybridDictionary – Dictionary&lt;&gt;h.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OrderedDictionary – Dictionary&lt;&gt;i.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SortedDictionary – Dictionary&lt;&gt;j.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NameValueCollection – Dictionary&lt;&gt;k.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DictionaryEntry – NameValuePair&lt;&gt;l.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringCollection – List&lt;String&gt;m.&nbsp;&nbsp;&nbsp;&nbsp; StringCollection – Dictionary&lt;String&gt;n.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Não tem relação - LinkedList&lt;&gt; 
·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;&gt; -o&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Generics Delegate: São declarados daqui seguinte forma:§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Public int Comparison&lt;TipoGenerico&gt; (Tx,Ty)·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Queue&lt;&gt;, Stack &lt;&gt; -&nbsp; Como os originais, só que se limitam aos tipos declarados·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GenericsDictionary&lt;&gt;: Diferencia-se do original somente pelo tipo de reotrno, antes era DictionaryEntry, agora KeyValuePair, resguardando a declaraco dos parâmetros.·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SortedList&lt;&gt;, SortedDictionary&lt;&gt; : Igual ao original·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LinkedList: Tem a mesma idéia dos ponteiro, com apontadores e talo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Propriedades:§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Count: Numero de componentes§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; First: Primeiro nó§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Last: último nóo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Métodos§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addAfter: Coloca depois de um certo nó§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addBefore: Coloca antes de um nó§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addFirst: Coloca no Inicio§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addLast: Coloca no Fim§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clear: Apaga Tudo§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contains: Verifica a existência§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; copyTo: Copia tudo prum array&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; §&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; find: Acha o primeiro contendo o valor§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; findLast: Acha o ultimo nó contendo o valor§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; remove:&nbsp; Remove pelo conteúdo ou pelo índice§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; removeFirst: Remove o primeiro§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; removeLast: Remove o último§&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; linkedNode: É cada item da LinkedList·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list: A lista de onde pertence o nó·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next: O próximo nó da lista·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; previous: O nó anterior·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value: O valor do nó §&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LinkedList: É uma composição de linked nodes