Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Sub Consumatore(c As IEnumerable)
- Console.WriteLine("Consumo con IEnumerable")
- Dim enumerator As IEnumerator = c.GetEnumerator
- While enumerator.MoveNext()
- Console.WriteLine(enumerator.Current)
- End While
- Console.WriteLine("------")
- End Sub
- Sub Main()
- Dim codaStringhe As New Queue(Of String) ' coda: gestione FIFO
- codaStringhe.Enqueue("Uno") ' accodamento
- codaStringhe.Enqueue("Due")
- codaStringhe.Enqueue("Tre")
- 'Console.WriteLine(codaStringhe.Dequeue()) ' consumo
- 'Console.WriteLine(codaStringhe.Dequeue()) ' consumo
- 'Console.WriteLine(codaStringhe.Dequeue()) ' consumo
- Console.WriteLine("Consumo di coda:")
- For Each item In codaStringhe
- Console.WriteLine(item)
- Next
- Console.WriteLine("-----")
- Dim pilaStringhe As New Stack(Of String) ' stack o pila: gestione LIFO
- pilaStringhe.Push("Uno") ' accodamento
- pilaStringhe.Push("Due") ' accodamento
- pilaStringhe.Push("Tre") ' accodamento
- 'Console.WriteLine(pilaStringhe.Pop()) ' consumo
- 'Console.WriteLine(pilaStringhe.Pop()) ' consumo
- 'Console.WriteLine(pilaStringhe.Pop()) ' consumo
- Console.WriteLine("Consumo di stack:")
- For Each item In pilaStringhe
- Console.WriteLine(item)
- Next
- Console.WriteLine("-----")
- Dim listaStringhe As New List(Of String) ' lista
- listaStringhe.Add("Uno") ' accodamento
- listaStringhe.Add("Tre")
- listaStringhe.Insert(1, "Due") 'inserimento
- Console.WriteLine(listaStringhe(0)) 'consumo
- Console.WriteLine(listaStringhe(1))
- Console.WriteLine(listaStringhe(2))
- Consumatore(listaStringhe)
- Dim hs As New HashSet(Of String) ' lista senza duplicati
- hs.Add("Uno") ' accodamento
- hs.Add("Tre")
- hs.Add("Due")
- hs.Add("Uno")
- For Each item In hs
- Console.WriteLine(item)
- Next
- Consumatore(hs)
- Dim dis As New Dictionary(Of Integer, String)
- dis.Add(1, "Uno")
- dis.Add(2, "Due")
- dis.Add(3, "Tre")
- Console.WriteLine(dis(3))
- Dim dsi As New Dictionary(Of String, Integer)
- dsi.Add("Pimo", 1)
- dsi.Add("Secondo", 2)
- dsi.Add("Terzo", 3)
- Console.WriteLine(dsi("Secondo"))
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement