<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-389511790892419567</atom:id><lastBuildDate>Fri, 01 Nov 2024 08:37:57 +0000</lastBuildDate><category>esempi di codice</category><category>Guida</category><category>Manuale italiano</category><category>Objective C</category><category>apple developer</category><category>programmare per iPhone e iPad</category><category>tutorial</category><category>Strutture Dati</category><category>animedb</category><category>film streaming</category><category>java</category><category>ffinalsqualo</category><category>siti streaming</category><category>anime streaming</category><category>film</category><category>megavideo</category><category>PositionList</category><category>classi</category><category>filmstreamingtv</category><category>giochi</category><category>help</category><category>migliori siti streaming</category><category>prova</category><category>serie tv</category><category>telefilm</category><category>5Mp</category><category>802.11n</category><category>AirPort Extreme</category><category>Antonio Di Natale</category><category>ArrayIndexList</category><category>ArrayIndexSequence</category><category>ArrayList</category><category>Bed and Breakfast</category><category>BinarySearchTree</category><category>Blue Moon</category><category>C++</category><category>Caffè Totò</category><category>Coda</category><category>Deque</category><category>Di Natale</category><category>Disney</category><category>Disneynature</category><category>Dock Spaces 2.20</category><category>Enabler per Mac</category><category>Firewire</category><category>GarageBand</category><category>Graph</category><category>Hotel</category><category>IndexList</category><category>LinkedBinaryTree</category><category>LinkedTree</category><category>Liste concatenate</category><category>Liste doppiamente concatenate</category><category>Mario Spina</category><category>Megavideo premium gratis</category><category>MiaSequenzaIncompleta</category><category>Nintendo</category><category>NodeList</category><category>NodePositionList</category><category>NodeSequence</category><category>Nokia</category><category>Position</category><category>Priority Queue</category><category>Privacy Policy</category><category>Queue</category><category>Quicksilver</category><category>Resort</category><category>San valentino di sangue 3d</category><category>Sant Agnello</category><category>Sapiens</category><category>Sequence</category><category>SequenzaIncompleta</category><category>Sorrento</category><category>SortedListPriorityQueue</category><category>Stack</category><category>Terra</category><category>Trailer</category><category>Trama</category><category>Trojan Leopard</category><category>USB3.0</category><category>UnsortedListPriorityQueue</category><category>Utility Disco</category><category>Youandus</category><category>aggirare limiti</category><category>airship f4</category><category>alberi</category><category>alberi binari</category><category>allocazione oggetti Obj-C</category><category>antivirus per mac</category><category>automatic turn off</category><category>barca volante</category><category>bleach</category><category>brushless</category><category>campania</category><category>caricabatterie solare</category><category>cartoons</category><category>catamarano volante</category><category>categorie</category><category>cellulari</category><category>cesto natalizio</category><category>chiusura sito</category><category>comportamenti statici</category><category>condiviisone schermo</category><category>connessioni internet</category><category>converter tool</category><category>convertitore</category><category>cooking mama 2</category><category>copertura</category><category>cura cancro</category><category>definizione classi</category><category>disegnare</category><category>dove comprare caffè totò</category><category>dove comprare maschera sub fotografica</category><category>dowload skype beta 2.8</category><category>download</category><category>download film</category><category>download telefilm</category><category>draw</category><category>dsi</category><category>dynamic binding</category><category>dynamic typing</category><category>ecologia</category><category>eludere limiti megavideo</category><category>enumerazione veloce</category><category>esercizi</category><category>estensioni</category><category>eztv</category><category>fai da te</category><category>feed</category><category>fluidtunes</category><category>fotomontaggi online</category><category>fotoritocco</category><category>fotovoltaico</category><category>freeware</category><category>fun photo box</category><category>games</category><category>gestione eccezioni</category><category>gioco scacchi</category><category>guadagna online</category><category>guadagnare</category><category>heap</category><category>heroes</category><category>hoste</category><category>hotmail</category><category>html</category><category>i protocolli</category><category>iAlertU</category><category>iConceal</category><category>iDvd</category><category>iLife &#39;09</category><category>iMovie</category><category>iPhoto</category><category>iWeb</category><category>immondizia</category><category>implementazione classi</category><category>inizializzare oggetti in Obj-C</category><category>interfacce</category><category>italia</category><category>italiano</category><category>iterable</category><category>iterator()</category><category>iterators</category><category>itunes</category><category>iworks</category><category>keynote</category><category>last minute</category><category>lost</category><category>mac</category><category>maestro di Judo</category><category>marvelcinema</category><category>maschera sub con fotocamera</category><category>meccanica quantistica</category><category>messaggi remoti</category><category>money</category><category>nanoparticelle</category><category>naruto</category><category>numbers</category><category>oggi in tv</category><category>one piece</category><category>pages</category><category>paint</category><category>paint online</category><category>password rubate</category><category>photoshop</category><category>php</category><category>play free chess</category><category>podcast</category><category>positions()</category><category>presentazione</category><category>proprietà</category><category>protezione files</category><category>reboot computer</category><category>remote messaging</category><category>restart computer</category><category>revver</category><category>riconoscitore canzoni</category><category>riferimenti associativi</category><category>rifiuti</category><category>rimedi morso di medusa</category><category>salute</category><category>scaricare video da youtube</category><category>schedule</category><category>selettori</category><category>shazam</category><category>shutdown</category><category>shutdown remote computer</category><category>sigaretta elettrica.</category><category>sito fotomontaggi</category><category>skype access</category><category>solare</category><category>soldi</category><category>soluzione</category><category>sos meduse</category><category>spegnere</category><category>spegnere computer</category><category>spegnere pc da remoto</category><category>spegnimento automatico pc</category><category>squaloweb</category><category>sub ita</category><category>subsfactory</category><category>sumo paint</category><category>synthesize</category><category>telefonia</category><category>televideo</category><category>televideo online</category><category>televideo rai</category><category>threads</category><category>tipatura statica</category><category>tipi di meduse</category><category>tunatic</category><category>tv online</category><category>underwater camera mask</category><category>verità</category><category>video</category><category>video download</category><category>video filmati iphone</category><category>videocamera</category><category>waterproof</category><category>web2.0</category><category>wii</category><category>wireless</category><category>youtube iphone</category><title>Nella vita di oggi...</title><description>Condividiamo le nostre esperienze, di vita, di studio, di lavoro, di sport. &quot;La sapienza è figlia dell&#39;esperienza&quot; (L. Da Vinci), quindi speriamo in qualche modo di poter essere utili a qualcuno raccontando ciò che ci accade e ci colpisce.</description><link>http://emdief.blogspot.com/</link><managingEditor>noreply@blogger.com (Unknown)</managingEditor><generator>Blogger</generator><openSearch:totalResults>77</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-3726918183326175135</guid><pubDate>Tue, 28 Jun 2011 11:30:00 +0000</pubDate><atom:updated>2011-06-28T13:30:11.576+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">BinarySearchTree</category><category domain="http://www.blogger.com/atom/ns#">Graph</category><category domain="http://www.blogger.com/atom/ns#">heap</category><category domain="http://www.blogger.com/atom/ns#">Strutture Dati</category><title>Strutture Dati - Tutto il Progetto</title><description>&lt;!--&lt;EdIndex&gt;--&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPWuJ8vJ3tyq9CJGbp8MNQqMBT1cJCL84RRO3eetsqzypmXwtL-VnVwpNhPTF1jyF0yWROEaW3-3d0E2l82HYISclJZ_9Ol_1BvBCuOR3-Eyeav0snc5zS1gR7ERXTge7V7gKNGmPuVcIk/s1600/eclipse.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPWuJ8vJ3tyq9CJGbp8MNQqMBT1cJCL84RRO3eetsqzypmXwtL-VnVwpNhPTF1jyF0yWROEaW3-3d0E2l82HYISclJZ_9Ol_1BvBCuOR3-Eyeav0snc5zS1gR7ERXTge7V7gKNGmPuVcIk/s200/eclipse.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Quando ho iniziato a seguire il corso di Strutture Dati ho anche iniziato a postare periodicamente le soluzioni dei miei esercizi, e le implementazioni delle strutture dati studiate fino a quel momento. Purtroppo man mano che la mole di studio si appesantiva non sono più stato in grado di stare al passo col blog, infatti l&#39;ultimo post risale alle code a priorità. Ho deciso quindi di postare direttamente tutto il &lt;b&gt;progetto&lt;/b&gt; a fine corso in formato &lt;b&gt;importabile direttamente in Eclipse&lt;/b&gt;. Quindi seguendo il link per il download alla fine di questo post potrete scaricare un progetto.zip&amp;nbsp;&lt;b&gt;comprendente tutte le Strutture Dati&lt;/b&gt;&amp;nbsp;&amp;nbsp;e le relative &lt;b&gt;classi di Test&lt;/b&gt;&amp;nbsp;che avevo già pubblicato in post precedenti&amp;nbsp;più quelle studiate successivamente (Heap, BinarySearchTree, Graph, Map, Dictionary, Partition), più tutti gli &lt;b&gt;esercizi&lt;/b&gt;, le 5 &lt;b&gt;prove intercorso&lt;/b&gt; del 2011, &lt;b&gt;e un Esame&lt;/b&gt; relativo al primo appello di Giugno.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
Per chi non sapesse come importare il progetto in Eclipse, ecco la procedura:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;ol&gt;&lt;li&gt;Scarica il file zippato dal link alla fine di questo post.&lt;/li&gt;
&lt;li&gt;Apri Eclipse&lt;/li&gt;
&lt;li&gt;clicca su un progetto esistente (OPZIONALE: fai questo per non dover selezionare una root directory successivamente)&lt;/li&gt;
&lt;li&gt;Dal Menu File in alto a sinistra seleziona la voce &quot;Import&quot;&lt;/li&gt;
&lt;li&gt;Dalla finestra che si aprirà, scegli &quot;Existing Project into Workspace&quot;&lt;/li&gt;
&lt;li&gt;Se non hai eseguito il punto 3, seleziona una root directory per il progetto&lt;/li&gt;
&lt;li&gt;Seleziona il file zip nel campo Archive File, e clicca sul pulsante Finish&lt;/li&gt;
&lt;/ol&gt;&lt;h4&gt;&lt;a href=&quot;https://rapidshare.com/files/3161675813/MarcoDiFioreLASD2011.zip&quot;&gt;Scarica Il Progetto&lt;/a&gt;&lt;/h4&gt;&lt;/span&gt; &lt;br /&gt;
&lt;!--&lt;/EdIndex&gt;--&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/06/strutture-dati-tutto-il-progetto.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPWuJ8vJ3tyq9CJGbp8MNQqMBT1cJCL84RRO3eetsqzypmXwtL-VnVwpNhPTF1jyF0yWROEaW3-3d0E2l82HYISclJZ_9Ol_1BvBCuOR3-Eyeav0snc5zS1gR7ERXTge7V7gKNGmPuVcIk/s72-c/eclipse.png" height="72" width="72"/><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-1620936001014578367</guid><pubDate>Tue, 19 Apr 2011 21:21:00 +0000</pubDate><atom:updated>2011-04-19T23:37:18.165+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">prova</category><category domain="http://www.blogger.com/atom/ns#">Strutture Dati</category><title>Strutture Dati - Prova del 19 Aprile</title><description>Ecco le mie soluzioni ai due esercizi della prova di Strutture Dati del 19 Aprile con il prof. Salvatore La Torre. &lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt; E Il primo esercizio consisteva nell&#39;implementare il metodo int maxValFoglie(BinaryTree&amp;lt;Integer&amp;gt; t) che restituisce il massimo tra i valori contenuti nelle foglie dell&#39;albero t:&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; maxValFoglie(BinaryTree&amp;lt;Integer&amp;gt; T)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; max = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterable&amp;lt;Position&amp;lt;Integer&amp;gt;&amp;gt; posizioni = T.positions();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Position&amp;lt;Integer&amp;gt;&amp;gt; it = posizioni.iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Position&amp;lt;Integer&amp;gt; curr = it.next();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (T.isExternal(curr))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;max = Math.max(max, curr.element());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; max;&lt;/div&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Monaco; font-size: 14px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Monaco; font-size: 14px;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;versione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ricorsiva&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black; white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; maxValFoglie(BinaryTree&amp;lt;Integer&amp;gt; T)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; maxValFoglie(T, T.root(), 0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; maxValFoglie(BinaryTree&amp;lt;Integer&amp;gt; T, Position&amp;lt;Integer&amp;gt; p, &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; max)&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(T.isExternal(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;max = Math.max(max, p.element());&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (T.hasLeft(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;max = maxValFoglie(T, T.left(p), max);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (T.hasRight(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;max = maxValFoglie(T, T.right(p), max);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; max;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Monaco; font-size: 14px;&quot;&gt;&lt;/span&gt;mentre il secondo consisteva nell&#39;implementare il metodo void forzaInorder(BinaryTree&amp;lt;E&amp;gt; t, PositionList&amp;lt;E&amp;gt; l) che a) testa se l&#39;albero t e la lista l hanno lo stesso numero di elementi; b) in caso affermativo, gli elementi di l sono copiati in t in modo che la visita inorder di t produca l&#39;ordine della lista l; c) in caso negativo viene lanciata una IrregularArgumentException:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; forzaInorder(BinaryTree&amp;lt;E&amp;gt; t, PositionList&amp;lt;E&amp;gt; l)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.size() != l.size())&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; IllegalArgumentException(&lt;/span&gt;&quot;Tree and Sequence are different&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;f(t,l,t.root());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; f (BinaryTree&amp;lt;E&amp;gt;t, PositionList&amp;lt;E&amp;gt;s, Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.hasLeft(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;f(t, s, t.left(p));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;t.replace(p, s.remove(s.first()));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.hasRight(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;f(t, s, t.right(p));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/04/strutture-dati-prova-del-19-aprile.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-1565654206276257781</guid><pubDate>Mon, 18 Apr 2011 17:42:00 +0000</pubDate><atom:updated>2011-04-18T19:42:32.185+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">PositionList</category><category domain="http://www.blogger.com/atom/ns#">Priority Queue</category><category domain="http://www.blogger.com/atom/ns#">SortedListPriorityQueue</category><category domain="http://www.blogger.com/atom/ns#">Strutture Dati</category><category domain="http://www.blogger.com/atom/ns#">UnsortedListPriorityQueue</category><title>Strutture Dati - Priority Queue</title><description>Dato che il tempo scorre in fretta inizio subito a postare l&#39;inizio degli esercizi che faremo domani in laboratorio sulle Code a Priorità, precisamente sono due implementazioni di PriorityQueue rispettivamente con lista ordinata, e non ordinata. Preciso che l&#39;elemento c di entrambe le classi è di tipo java.util.Comparator e che l&#39;implementazione di DefaultComparator la trovate sulle slides del prof (&lt;a href=&quot;http://www.dia.unisa.it/professori/latorre/didattica/SD/Slides/Lez07b.pdf&quot;&gt;lez07&lt;/a&gt;). In bocca al lupo per la probabile prova su alberi e tour euleriani di domani a tutti i miei compagni di corso.  &lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Monaco; font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Monaco; font-size: 14px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Monaco; font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Monaco; font-size: 14px;&quot;&gt; SortedListPriorityQueue&amp;lt;K,V&amp;gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Monaco; font-size: 14px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Monaco; font-size: 14px;&quot;&gt; PriorityQueue&amp;lt;K,V&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; PositionList&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; Comparator&amp;lt;K&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;protected&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;static&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;class&lt;span style=&quot;color: black;&quot;&gt; MyEntry&amp;lt;K,V&amp;gt; &lt;/span&gt;implements&lt;span style=&quot;color: black;&quot;&gt; Entry&amp;lt;K,V&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;protected&lt;span style=&quot;color: black;&quot;&gt; K &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;protected&lt;span style=&quot;color: black;&quot;&gt; V &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; MyEntry(K key, V value)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;k&lt;/span&gt; = key;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;v&lt;/span&gt; = value;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; K getKey() {&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;k&lt;/span&gt;;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; V getValue() {&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;v&lt;/span&gt;;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString() { &lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;(k:&quot;&lt;/span&gt;+&lt;span style=&quot;color: #0000d0;&quot;&gt;k&lt;/span&gt;+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; v:&quot;&lt;/span&gt;+&lt;span style=&quot;color: #0000d0;&quot;&gt;v&lt;/span&gt;+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;)&quot;&lt;/span&gt;; }&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; SortedListPriorityQueue()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; DefaultComparator&amp;lt;K&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; SortedListPriorityQueue(Comparator&amp;lt;K&amp;gt; comp)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt; = comp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.size();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.size() == 0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Entry&amp;lt;K, V&amp;gt; min() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyPriorityQueueException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Position&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; min;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyPriorityQueueException();&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;min = &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.first();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Position&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; prossimo = min;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=1; i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.size(); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;prossimo = &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.next(prossimo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt;.compare(min.element().getKey(), prossimo.element().getKey()) &amp;gt; 0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;min=prossimo;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; min.element();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Entry&amp;lt;K, V&amp;gt; insert(K key, V value) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidKeyException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkKey(key);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Entry&amp;lt;K,V&amp;gt; entry = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; MyEntry&amp;lt;K,V&amp;gt;(key, value);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;insertEntry(entry);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; entry;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Entry&amp;lt;K, V&amp;gt; removeMin() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyPriorityQueueException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyPriorityQueueException();&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.remove(&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.first());&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; checkKey(K key)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; result;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;try&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;result = (&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt;.compare(key,key)==0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;catch&lt;/span&gt; (ClassCastException e)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidKeyException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Not Comparable Key&quot;&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; result;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; insertEntry(Entry&amp;lt;K,V&amp;gt; e)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.addFirst(e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt;.compare(e.getKey(), &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.last().element().getKey())&amp;gt; 0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.addLast(e);&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Position&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; curr = &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.first();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt;.compare(e.getKey(), curr.element().getKey())&amp;gt;0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;curr = &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.next(curr);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.addBefore(curr, e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&quot;Empty PQ&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String s=&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;[ &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; it = &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += it.next()+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; s+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;] size:&quot;&lt;/span&gt;+size()+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; min:&quot;&lt;/span&gt;+min();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; UnsortedListPriorityQueue&amp;lt;K,V&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; PriorityQueue&amp;lt;K,V&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; PositionList&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; Comparator&amp;lt;K&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;protected&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;static&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;class&lt;span style=&quot;color: black;&quot;&gt; MyEntry&amp;lt;K,V&amp;gt; &lt;/span&gt;implements&lt;span style=&quot;color: black;&quot;&gt; Entry&amp;lt;K,V&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;protected&lt;span style=&quot;color: black;&quot;&gt; K &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;k&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;protected&lt;span style=&quot;color: black;&quot;&gt; V &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;v&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; MyEntry(K key, V value)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;k&lt;/span&gt; = key;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;v&lt;/span&gt; = value;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; K getKey() {&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;k&lt;/span&gt;;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; V getValue() {&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;v&lt;/span&gt;;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString() { &lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;(k:&quot;&lt;/span&gt;+&lt;span style=&quot;color: #0000d0;&quot;&gt;k&lt;/span&gt;+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; v:&quot;&lt;/span&gt;+&lt;span style=&quot;color: #0000d0;&quot;&gt;v&lt;/span&gt;+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;)&quot;&lt;/span&gt;; }&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; UnsortedListPriorityQueue()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; DefaultComparator&amp;lt;K&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; UnsortedListPriorityQueue(Comparator&amp;lt;K&amp;gt; comp)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt; = comp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.size();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.size() == 0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Entry&amp;lt;K, V&amp;gt; min() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyPriorityQueueException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Position&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; min;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyPriorityQueueException();&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;min = &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.first();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Position&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; prossimo = min;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=1; i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.size(); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;prossimo = &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.next(prossimo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt;.compare(min.element().getKey(), prossimo.element().getKey()) &amp;gt; 0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;min=prossimo;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; min.element();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Entry&amp;lt;K, V&amp;gt; insert(K key, V value) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidKeyException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkKey(key);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Entry&amp;lt;K,V&amp;gt; entry = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; MyEntry&amp;lt;K,V&amp;gt;(key, value);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.addLast(entry);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; entry;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Entry&amp;lt;K, V&amp;gt; removeMin() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyPriorityQueueException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Position&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; min;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyPriorityQueueException();&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;min = &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.first();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Position&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; prossimo = min;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=1; i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.size(); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;prossimo = &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.next(prossimo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt;.compare(min.element().getKey(), prossimo.element().getKey()) &amp;gt; 0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;min=prossimo;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.remove(min);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; checkKey(K key)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; result;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;try&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;result = (&lt;span style=&quot;color: #0000d0;&quot;&gt;c&lt;/span&gt;.compare(key,key)==0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;catch&lt;/span&gt; (ClassCastException e)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidKeyException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;UnComparable Key&quot;&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; result;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&quot;Empty PQ&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String s=&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;[ &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Entry&amp;lt;K,V&amp;gt;&amp;gt; it = &lt;span style=&quot;color: #0000d0;&quot;&gt;entries&lt;/span&gt;.iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += it.next()+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; s+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;] size:&quot;&lt;/span&gt;+size()+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; min:&quot;&lt;/span&gt;+min();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/04/strutture-dati-priority-queue.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-8999743239888038122</guid><pubDate>Sat, 16 Apr 2011 15:35:00 +0000</pubDate><atom:updated>2011-04-17T13:19:24.421+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">alberi</category><category domain="http://www.blogger.com/atom/ns#">alberi binari</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">LinkedBinaryTree</category><category domain="http://www.blogger.com/atom/ns#">LinkedTree</category><category domain="http://www.blogger.com/atom/ns#">Strutture Dati</category><title>Strutture Dati - Tree and Binary Tree</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCTjS4oeH6guv1FxI959v4wnjhcSq2c6pe1XlpVVWO5z4MFL9tYqcj3Sf_KmvgQeyf4j5QJnBQH0wS5Zjk1jmTGM2pcKffh8LxpA0Joq9ZFvD8-yZnlib4zdspM4i33bR8N3WVj07Z9Uk0/s1600/binarytree.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCTjS4oeH6guv1FxI959v4wnjhcSq2c6pe1XlpVVWO5z4MFL9tYqcj3Sf_KmvgQeyf4j5QJnBQH0wS5Zjk1jmTGM2pcKffh8LxpA0Joq9ZFvD8-yZnlib4zdspM4i33bR8N3WVj07Z9Uk0/s1600/binarytree.png&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy7ihpIxDmHh_xMIm-B_PY3RgdgolaIMFcRpE6QrLd7jT02mXS3PQALA4KFOS4JfxdS2lRIZSHNGRUDTDrLwonUZzOUerRkZ87hzxefLyqVIfaziYC9Q-XCv-qThaiFxf2eMCG6-6f5J3C/s1600/tree.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy7ihpIxDmHh_xMIm-B_PY3RgdgolaIMFcRpE6QrLd7jT02mXS3PQALA4KFOS4JfxdS2lRIZSHNGRUDTDrLwonUZzOUerRkZ87hzxefLyqVIfaziYC9Q-XCv-qThaiFxf2eMCG6-6f5J3C/s1600/tree.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Ecco un altro post sulle Strutture Dati, come da programma passiamo agli Alberi e gli Alberi Binari, non posto anche le implementazioni di EulerTour dato che si possono copiare dalle slides del prof, e inoltre ho dovuto rallentare il ritmo perché il tempo è sempre meno.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; LinkedTree&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; Tree&amp;lt;E&amp;gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; TreePosition&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;protected&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; LinkedTree()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; TreeNode&amp;lt;E&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; LinkedTree(E rootElement)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;addRoot(rootElement);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; LinkedTree(TreePosition&amp;lt;E&amp;gt; r)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt; = r;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt; != &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; = r.getChildren().size()+1;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; = 1;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterator&amp;lt;E&amp;gt; iterator()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterable&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; positions = positions();&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PositionList&amp;lt;E&amp;gt; elements = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;E&amp;gt;();&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(Position&amp;lt;E&amp;gt; pos: positions)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;elements.addLast(pos.element());&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; elements.iterator();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; == 0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterable&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; positions()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; lista = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; != 0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;preorderPosition(root(), lista);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; lista;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E replace(Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; nodo = (TreeNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp = nodo.element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;nodo.setElement(e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; root() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyTreeException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyTreeException();&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; parent(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException, BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; tmp = (TreeNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (tmp == &lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; BoundaryViolationException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Root has no parent!&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp.&lt;span style=&quot;color: #0000d0;&quot;&gt;parent&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterable&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; children(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; nodo = (TreeNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(isExternal(nodo))&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InvalidPositionException(&lt;/span&gt;&quot;External nodes do not have children!&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; nodo.getChildren();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isInternal(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (!isExternal(p));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isExternal(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; nodo = (TreeNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (nodo.getChildren() == &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isRoot(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; nodo = (TreeNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (nodo.equals(root()));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; TreePosition&amp;lt;E&amp;gt; checkPosition(Position&amp;lt;E&amp;gt; p)&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (p == &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt; || !(p &lt;span style=&quot;color: #a10068;&quot;&gt;instanceof&lt;/span&gt; TreePosition))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (TreePosition&amp;lt;E&amp;gt;) p;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; preorderPosition(Position&amp;lt;E&amp;gt; p, PositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; pos) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;pos.addLast(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isExternal(p))&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; it = children(p).iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;preorderPosition(it.next(),pos);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; postorderPosition(Position&amp;lt;E&amp;gt; p, PositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; pos) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isInternal(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Iterator&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; it = children(p).iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;postorderPosition(it.next(),pos);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;pos.addLast(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String printPreOrder()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String s =&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;[ &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; lista = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;preorderPosition(&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;, lista);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; it = lista.iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += it.next().element() + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; s + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;]&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String printPostOrder()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String s =&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;[ &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; lista = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;postorderPosition(&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;, lista);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; it = lista.iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += it.next().element() + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; s + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;]&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;metodo&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;personale&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;che&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;stampa&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nodo&lt;/span&gt; e &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;suo&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;eventuale&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sottoalbero&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; String stampaNodo(Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String s = &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;depth(p); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;&amp;nbsp; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;s += p.element().toString();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; n = (TreeNode&amp;lt;E&amp;gt;) checkPosition (p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isExternal(n))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; s +=&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;\n&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;-&amp;gt;\n&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; it = n.getChildren().iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt; (it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += stampaNodo(it.next());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; s;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&quot;EmptyTree&quot;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; stampaNodo((TreeNode&amp;lt;E&amp;gt;) root())+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; size:&quot;&lt;/span&gt;+&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; addChild(E e, Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; padre = (TreeNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; newNode = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; TreeNode&amp;lt;E&amp;gt;(e,padre,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isExternal(padre))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; figli = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;figli.addLast(newNode);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;padre.setChildren(figli);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;padre.getChildren().addLast(newNode);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; newNode;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; removeChild(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; nodo = (TreeNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isExternal(nodo))&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InvalidPositionException(&lt;/span&gt;&quot;This Node has no children to remove&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; childToRemove =&amp;nbsp; (TreeNode&amp;lt;E&amp;gt;) nodo.getChildren().first().element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; numFigli = childCounter(childToRemove);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;nodo.getChildren().remove(nodo.getChildren().first());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; -= numFigli;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (nodo.getChildren().size() == 0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;nodo.setChildren(&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; childToRemove;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;conta&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;numero&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;figli&lt;/span&gt; +1 &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nodo&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; childCounter(Position&amp;lt;E&amp;gt;p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; nodo = (TreeNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isExternal(nodo))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; 1;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; numFigli = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(Position&amp;lt;E&amp;gt; figlio : children(nodo))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;numFigli += childCounter(figlio);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; 1 + numFigli;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; addRoot(E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; NonEmptyTreeException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (!isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NonEmptyTreeException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Root exists already!&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;E&amp;gt; newRoot = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; TreeNode&amp;lt;E&amp;gt;(e,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; = 1;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt; = newRoot;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; depth(Position&amp;lt;E&amp;gt; p)&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;/*//&lt;span style=&quot;text-decoration: underline;&quot;&gt;ricorsivo&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp; if (isRoot(p)) return 0;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp; return 1+depth(parent(p));&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreePosition&amp;lt;E&amp;gt; nodo = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(isRoot(nodo))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; depth=1;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreePosition&amp;lt;E&amp;gt; par = nodo.getParent();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(!isRoot(par))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;par=par.getParent();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;depth++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; depth;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/*&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; //&lt;span style=&quot;text-decoration: underline;&quot;&gt;metodo&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ricorsivo&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; public &lt;span style=&quot;text-decoration: underline;&quot;&gt;int&lt;/span&gt; height(Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; if (isExternal(p) return 0;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; else&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;int&lt;/span&gt; max = 0;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(Position&amp;lt;E&amp;gt; child : children(p))&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;max = Math.max(max, height(child));&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return max+1;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; }&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; height()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; altezza(root());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; altezza(Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isExternal(p))&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #a10068;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; h = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Iterator&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; children = children(p).iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(children.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;h = Math.max(h, altezza(children.next()));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (1 + h);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #a10068; font-family: Monaco; font-size: medium;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;computa&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;somma&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;degli&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elementi&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;albero&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;interi&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; sum(LinkedTree&amp;lt;Integer&amp;gt; t)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyTreeException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; sum(t.root(),t);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/*&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * postSum &lt;span style=&quot;text-decoration: underline;&quot;&gt;mi&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;calcola&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;somma&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;del&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nodo&lt;/span&gt; p + &lt;span style=&quot;text-decoration: underline;&quot;&gt;tutti&lt;/span&gt; i &lt;span style=&quot;text-decoration: underline;&quot;&gt;suoi&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;figli&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; sum(Position&amp;lt;Integer&amp;gt; p, LinkedTree&amp;lt;Integer&amp;gt; t)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TreeNode&amp;lt;Integer&amp;gt; nodo = (TreeNode&amp;lt;Integer&amp;gt;) t.checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; sum = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.isInternal(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(Position&amp;lt;Integer&amp;gt; pos : nodo.getChildren())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;sum += sum( pos,t);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (sum + p.element());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;restituisce&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; Position dell&#39;elemento x &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; è &lt;span style=&quot;text-decoration: underline;&quot;&gt;presente&lt;/span&gt; nell&#39;albero t&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//null &lt;span style=&quot;text-decoration: underline;&quot;&gt;altrimenti&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &amp;lt;E&amp;gt; Position&amp;lt;E&amp;gt; findElt(Tree&amp;lt;E&amp;gt; t, E x)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyTreeException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; find(t,t.root(),x);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &amp;lt;E&amp;gt; Position&amp;lt;E&amp;gt; find(Tree&amp;lt;E&amp;gt; t, Position&amp;lt;E&amp;gt; p, E x)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (p.element().equals(x))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; p;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.isExternal(p))&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;null&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(Position&amp;lt;E&amp;gt; pos : t.children(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Position&amp;lt;E&amp;gt; ris = find(t,pos,x);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (ris != &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; ris;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;null&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; LinkedBinaryTree&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; BinaryTree&amp;lt;E&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; BTNode&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; LinkedBinaryTree()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; LinkedBinaryTree(E e)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;addRoot(e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;==0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterable&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; positions()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; lista = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; != 0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;preorderPositions(root(), lista);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; lista;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E replace(Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; nodo = (BTNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp = nodo.element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;nodo.setElement(e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; root() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyTreeException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyTreeException();&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; parent(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException, BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; tmp = (BTNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (tmp.equals(&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; BoundaryViolationException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Root has no parent!&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp.getParent();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterable&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; children(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; nodo = (BTNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(isExternal(nodo))&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InvalidPositionException(&lt;/span&gt;&quot;External nodes do not have children!&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; figli = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;figli.addFirst(nodo.getLeft());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;figli.addLast(nodo.getRight());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; figli;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isInternal(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (!isExternal(p));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isExternal(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; nodo = (BTNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (nodo.getLeft()==&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; nodo.getRight()==&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isRoot(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; nodo = (BTNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (nodo.equals(&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterator&amp;lt;E&amp;gt; iterator()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterable&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; positions = positions();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PositionList&amp;lt;E&amp;gt; elements = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;E&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; it = positions.iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;elements.addLast(it.next().element());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; elements.iterator();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; left(Position&amp;lt;E&amp;gt; v) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException,&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTPosition&amp;lt;E&amp;gt; nodo = checkPosition(v);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(isExternal(v))&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InvalidPositionException(&lt;/span&gt;&quot;External nodes have no children&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(!hasLeft(v))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; BoundaryViolationException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;This node has not a left chlid&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; nodo.getLeft();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; right(Position&amp;lt;E&amp;gt; v) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException, BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTPosition&amp;lt;E&amp;gt; nodo = checkPosition(v);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(isExternal(v))&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InvalidPositionException(&lt;/span&gt;&quot;External nodes have no children&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(!hasRight(v))&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; BoundaryViolationException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;This node has not a right chlid&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; nodo.getRight();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; hasLeft(Position&amp;lt;E&amp;gt; v) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTPosition&amp;lt;E&amp;gt; nodo = checkPosition(v);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(nodo.getLeft()==&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;false&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;true&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; hasRight(Position&amp;lt;E&amp;gt; v) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTPosition&amp;lt;E&amp;gt; nodo = checkPosition(v);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(nodo.getRight()==&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;false&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;true&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; preorderPositions(Position&amp;lt;E&amp;gt; v, PositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; pos) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;pos.addLast(v);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (hasLeft(v))&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;preorderPositions(left(v), pos);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (hasRight(v))&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;preorderPositions(right(v), pos);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; BTPosition&amp;lt;E&amp;gt; checkPosition(Position&amp;lt;E&amp;gt; p)&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (p == &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt; || !(p &lt;span style=&quot;color: #a10068;&quot;&gt;instanceof&lt;/span&gt; BTPosition))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (BTPosition&amp;lt;E&amp;gt;) p;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; BTPosition&amp;lt;E&amp;gt; addRoot(E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; NonEmptyTreeException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(!isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NonEmptyTreeException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Root exists already&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt;nodo = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; BTNode&amp;lt;E&amp;gt;(e,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt; = nodo;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; = 1;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;root&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;metodo&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;personale&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;che&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;stampa&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nodo&lt;/span&gt; e &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;suo&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;eventuale&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sottoalbero&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; String stampaNodo(Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String s = &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;depth(p); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;&amp;nbsp; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;s += p.element().toString();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; n = (BTNode&amp;lt;E&amp;gt;) checkPosition (p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isExternal(n))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; s +=&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;\n&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;-&amp;gt;\n&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; figli = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (hasLeft(n))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;figli.addFirst(n.getLeft());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(hasRight(n))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;figli.addLast(n.getRight());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; it = figli.iterator();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt; (it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += stampaNodo(it.next());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; s;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&quot;EmptyTree&quot;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; stampaNodo((BTNode&amp;lt;E&amp;gt;) root())+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; size: &quot;&lt;/span&gt;+&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; depth(Position&amp;lt;E&amp;gt; p)&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTPosition&amp;lt;E&amp;gt; nodo = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(isRoot(nodo))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; prof=1;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTPosition&amp;lt;E&amp;gt; par = nodo.getParent();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(!isRoot(par))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;par=par.getParent();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;prof++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; prof;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;/*&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;* &lt;span style=&quot;text-decoration: underline;&quot;&gt;Scrivere&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;metodo&lt;/span&gt; InsertLeft &lt;span style=&quot;text-decoration: underline;&quot;&gt;che&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;prende&lt;/span&gt; in input&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;* &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elemento&lt;/span&gt; e e &lt;span style=&quot;text-decoration: underline;&quot;&gt;una&lt;/span&gt; position p,&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;* &lt;span style=&quot;text-decoration: underline;&quot;&gt;inserisce&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;figlio&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sinistro&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; p &lt;span style=&quot;text-decoration: underline;&quot;&gt;con&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elemento&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;* e &lt;span style=&quot;text-decoration: underline;&quot;&gt;restituisce&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;riferimento&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;alla&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nuova&lt;/span&gt; position &lt;span style=&quot;text-decoration: underline;&quot;&gt;inserita&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;*&amp;nbsp; (&lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;figlio&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sx&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;esiste&lt;/span&gt;, &lt;span style=&quot;text-decoration: underline;&quot;&gt;lancia&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;eccezione&lt;/span&gt;)*/&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; insertLeft(E e, Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; nodo = (BTNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (hasLeft(nodo))&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InvalidPositionException(&lt;/span&gt;&quot;The node already has a left child.&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; newNode = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; BTNode&amp;lt;E&amp;gt;(e,nodo,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;nodo.setLeft(newNode);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; newNode;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; insertRight(E e, Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; nodo = (BTNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (hasRight(nodo))&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InvalidPositionException(&lt;/span&gt;&quot;The node already has a right child.&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; newNode = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; BTNode&amp;lt;E&amp;gt;(e,nodo,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;nodo.setRight(newNode);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; newNode;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; height()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; altezza(root());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; altezza(Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isExternal(p))&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #a10068;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; h = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;BTNode&amp;lt;E&amp;gt; nodo = (BTNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;h = Math.max(altezza(nodo.getLeft()), altezza(nodo.getRight()));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (1 + h);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;rimuove&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;figlio&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sinistro&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; p&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; removeLeft(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; nodo = (BTNode&amp;lt;E&amp;gt;)checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (!hasLeft(nodo))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;The node has not a left child.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; childToRemove = (BTNode&amp;lt;E&amp;gt;) nodo.getLeft();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; -= childCounter(childToRemove);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;nodo.setLeft(&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; childToRemove;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;rimuove&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;figlio&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;destro&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; p&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; removeRight(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; nodo = (BTNode&amp;lt;E&amp;gt;)checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (!hasRight(nodo))&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InvalidPositionException(&lt;/span&gt;&quot;The node has not a right child.&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; childToRemove = (BTNode&amp;lt;E&amp;gt;) nodo.getRight();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; -= childCounter(childToRemove);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;nodo.setLeft(&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; childToRemove;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;conta&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;numero&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;figli&lt;/span&gt; +1 &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nodo&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; childCounter(Position&amp;lt;E&amp;gt;p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;BTNode&amp;lt;E&amp;gt; nodo = (BTNode&amp;lt;E&amp;gt;) checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isExternal(nodo))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; 1;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; numFigli = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(Position&amp;lt;E&amp;gt; figlio : children(nodo))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;numFigli += childCounter(figlio);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; 1 + numFigli;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #a10068;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; sum(LinkedBinaryTree&amp;lt;Integer&amp;gt; t)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; sum(t.root(),t);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; sum(Position&amp;lt;Integer&amp;gt; p, LinkedBinaryTree&amp;lt;Integer&amp;gt; t)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; sum = p.element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.isInternal(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.hasLeft(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;sum += sum(t.left(p), t);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.hasRight(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;sum += sum(t.right(p), t);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; sum;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;verifica&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;che&lt;/span&gt; l&#39;ordine &lt;span style=&quot;text-decoration: underline;&quot;&gt;degli&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elementi&lt;/span&gt; dell&#39;albero &lt;span style=&quot;text-decoration: underline;&quot;&gt;visitati&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;inorder&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;rispecchia&lt;/span&gt; l&#39;ordine &lt;span style=&quot;text-decoration: underline;&quot;&gt;degli&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elementi&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;della&lt;/span&gt; sequence&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; checkOrder(BinaryTree&amp;lt;E&amp;gt;t, Sequence&amp;lt;E&amp;gt; s)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyTreeException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(s.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptySequenceException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.size() != s.size())&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; NotEnoughElements(&lt;/span&gt;&quot;Tree and Sequence are different&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; f(t,s,t.root());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; f (BinaryTree&amp;lt;E&amp;gt;t, Sequence&amp;lt;E&amp;gt;s, Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.hasLeft(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (!f(t, s, t.left(p)))&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;false&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (!p.element().equals(s.first().element()))&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;false&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;s.removeFirst();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (t.hasRight(p))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (!f(t, s, t.right(p)))&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;false&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;true&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; }&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/04/strutture-dati-tree-and-binary-tree_16.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCTjS4oeH6guv1FxI959v4wnjhcSq2c6pe1XlpVVWO5z4MFL9tYqcj3Sf_KmvgQeyf4j5QJnBQH0wS5Zjk1jmTGM2pcKffh8LxpA0Joq9ZFvD8-yZnlib4zdspM4i33bR8N3WVj07Z9Uk0/s72-c/binarytree.png" height="72" width="72"/><thr:total>12</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-4538148237643136718</guid><pubDate>Thu, 07 Apr 2011 23:31:00 +0000</pubDate><atom:updated>2011-04-11T11:10:43.968+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">caricabatterie solare</category><category domain="http://www.blogger.com/atom/ns#">ecologia</category><category domain="http://www.blogger.com/atom/ns#">fai da te</category><category domain="http://www.blogger.com/atom/ns#">fotovoltaico</category><category domain="http://www.blogger.com/atom/ns#">Nokia</category><category domain="http://www.blogger.com/atom/ns#">solare</category><title>Caricare il cellulare con un caricabatterie solare usb fai da te</title><description>Salve ragazzi questo post è dedicato all&#39;ambiente, navigando ho trovato questi due links utilissimi che mi permetteranno presto di creare un caricabatterie solare usb con pochi spiccioli, e un cavo per caricare il mio cellulare Nokia tramite porta Usb, e volevo condividere queste informazioni preziose con voi. &lt;br /&gt;
&lt;br /&gt;
Questo è il &lt;a href=&quot;http://www.gadgetblog.it/post/3135/caricatore-nokia-usb-fatto-in-casa&quot;&gt;link&lt;/a&gt; per creare un cavo per caricare il proprio cellulare Nokia tramite porta usb&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.gadgetblog.it/post/3135/caricatore-nokia-usb-fatto-in-casa&quot;&gt;&lt;span id=&quot;goog_505740184&quot;&gt;&lt;/span&gt;&lt;img border=&quot;0&quot; height=&quot;140&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWLVqaZh-h-tmzGAp0X9DxdPrydIJcX6QN2xJYwyVyfgPGS8Ss8Ptter8fME8Jpfy-ZwFjE1sfDYe3m_dCRV7Usb_VmrsNqtNbIGVhFj9BaORoPmVR380tr88pDCfIeVTN9YvGMzzWU99P/s200/caricatore_usb_nokia_cavo.jpg&quot; width=&quot;200&quot; /&gt;&lt;span id=&quot;goog_505740185&quot;&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
e questo è il &lt;a href=&quot;http://www.metacafe.com/watch/800000/solar_powered_usb_charger_cheap_and_easy_to_make/&quot;&gt;link del Video&lt;/a&gt; che dice come assemblare delle mini celle fotovoltaiche per comporre un caricabatterie solare portatile.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.metacafe.com/watch/800000/solar_powered_usb_charger_cheap_and_easy_to_make/&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;149&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDGK2eubcX7ewgmnVwZ0TG7FF3FWvby73QojxsXIN3Kmzj7g-43ygNDwEqTNl6T_vVxIyGFavT0dIam9X-2WvfGlZuoTyl8JNtTL-kmhzL-Ufkb2JdN4nqKvrhUxx_piZSR_2Kb3AzxpUv/s200/Schermata+2011-04-11+a+11.07.25.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Su Ebay ho trovato delle celle fotovoltaiche identiche a quelle del video, 5 celle a meno di 20 € spedizione inclusa!&lt;br /&gt;
&lt;br /&gt;
W IL SOLE, ABBASSO IL PETROLIO!!!&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;E per i più arditi.... ecco un video su come autocostruirsi una cella fotovoltaica all&#39;ossido di rame&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;center&gt;&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;255&quot; src=&quot;http://www.youtube.com/embed/jL1KiWN26Q0&quot; title=&quot;YouTube video player&quot; width=&quot;400&quot;&gt;&lt;/iframe&gt;&lt;/center&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/04/caricare-il-cellulare-con-un.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWLVqaZh-h-tmzGAp0X9DxdPrydIJcX6QN2xJYwyVyfgPGS8Ss8Ptter8fME8Jpfy-ZwFjE1sfDYe3m_dCRV7Usb_VmrsNqtNbIGVhFj9BaORoPmVR380tr88pDCfIeVTN9YvGMzzWU99P/s72-c/caricatore_usb_nokia_cavo.jpg" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-7456952844605058746</guid><pubDate>Thu, 07 Apr 2011 14:03:00 +0000</pubDate><atom:updated>2011-04-08T01:43:52.487+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iterable</category><category domain="http://www.blogger.com/atom/ns#">iterator()</category><category domain="http://www.blogger.com/atom/ns#">iterators</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">positions()</category><category domain="http://www.blogger.com/atom/ns#">Strutture Dati</category><title>Strutture Dati - Iterator e positions()</title><description>&lt;!--&lt;EdIndex&gt;--&gt;Quinto post dedicato alle Strutture Dati, oggi di preciso implementeremo l&#39;interfaccia &lt;b&gt;java.lang.Iterable&lt;/b&gt; nelle strutture dati dei post precedenti (vedere il metodo iterator() ). Un Iteratore è un&#39;oggetto che permette di scandire gli elementi di un contenitore a prescindere dalla sua implementazione.&lt;br /&gt;
&lt;br /&gt;
Ci sono due modi di implementare un iteratore: &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;uno è quello di &lt;b&gt;usare una&lt;/b&gt; qualsiasi &lt;b&gt;struttura dati&lt;/b&gt; che fornisca un accesso sequenziale ai suoi elementi, in questo caso il costruttore dell&#39;iteratore impiegherà tempo O(n) per copiare tutti gli elementi della struttura nell&#39;iteratore; ma l&#39;iteratore creato in questo modo andrà bene per qualunque struttura dati&lt;/li&gt;
&lt;li&gt;un altro è quello di &lt;b&gt;utilizzare un cursore&lt;/b&gt;, cioè una variabile che tenga traccia dell&#39;elemento corrente, in questo modo il costruttore dell&#39;iteratore non dovrà copiare tutti gli elementi della struttura, ma utilizzerà un riferimento ad essa impiegando tempo O(1); lo svantaggio nell&#39;uso di un cursore è quello di dover fornire un&#39;implementazione specifica di Iterator per ogni tipo di Struttura Dati.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
Una volta introdotto il concetto di iteratori e iterabilità possiamo aggiungere a tutti i Tipi di Dato Astratto che implementano il concetto di Position, il metodo Iterable&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; positions()&lt;br /&gt;
che restituisce una collezione iterabile contenente le posizioni del TDA come elementi. Per fare ciò, aggiungiamo la firma di questo metodo all&#39;interfaccia PositionList vista nel &lt;a href=&quot;http://emdief.blogspot.com/2011/03/strutture-dati-arraylist-e-nodelist.html&quot;&gt;3°post&lt;/a&gt; di questa serie, e lo implementiamo in tutte le classi che implementano quest&#39;interfaccia.&lt;br /&gt;
&lt;!--&lt;/EdIndex&gt;--&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; LinkedIterator&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; Iterator&amp;lt;E&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; Node&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;nodo&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;costruttore&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;richiede&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;tempo&lt;/span&gt; O(n) per &lt;span style=&quot;text-decoration: underline;&quot;&gt;copiare&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;gli&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elementi&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; LinkedIterator(E[] a)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;nodo&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;size&lt;span style=&quot;color: black;&quot;&gt; = a.&lt;/span&gt;length&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1; i&amp;gt;=0; i--)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Node&amp;lt;E&amp;gt; tmp = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; Node&amp;lt;E&amp;gt;(a[i],&lt;span style=&quot;color: #0000d0;&quot;&gt;nodo&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;nodo&lt;/span&gt; = tmp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; hasNext()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&amp;gt;0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E next()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp = &lt;span style=&quot;color: #0000d0;&quot;&gt;nodo&lt;/span&gt;.getElement();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;remove();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; remove()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (!hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NoSuchElementException();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;nodo&lt;/span&gt; = &lt;span style=&quot;color: #0000d0;&quot;&gt;nodo&lt;/span&gt;.getNext();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;--;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; ElementIterator&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; Iterator&amp;lt;E&amp;gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; PositionList&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;lista&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; Position&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;cur&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;costruttore&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;questa&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;classe&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;impiega&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;tempo&lt;/span&gt; O(1)&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//a &lt;span style=&quot;text-decoration: underline;&quot;&gt;differenza&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;quello&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; LinkedIterator &lt;span style=&quot;text-decoration: underline;&quot;&gt;che&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ne&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;impiegava&lt;/span&gt; O(n)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; ElementIterator(PositionList&amp;lt;E&amp;gt; L)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;lista&lt;/span&gt; = L;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (!L.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;cur&lt;/span&gt; = L.first();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; hasNext()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;cur&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;!=&lt;/span&gt;null&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E next() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; NoSuchElementException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;lista&lt;/span&gt;.isEmpty())&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; NoSuchElementException(&lt;/span&gt;&quot;Lista vuota! next() non possibile&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp = &lt;span style=&quot;color: #0000d0;&quot;&gt;cur&lt;/span&gt;.element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;cur&lt;/span&gt; == &lt;span style=&quot;color: #0000d0;&quot;&gt;lista&lt;/span&gt;.last())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;cur&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;cur&lt;/span&gt; = &lt;span style=&quot;color: #0000d0;&quot;&gt;lista&lt;/span&gt;.next(&lt;span style=&quot;color: #0000d0;&quot;&gt;cur&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; remove() {}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; IndexListIterator&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; Iterator&amp;lt;E&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; IndexList&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;a&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; IndexListIterator(IndexList&amp;lt;E&amp;gt; A)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;a&lt;/span&gt; = A;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (!&lt;span style=&quot;color: #0000d0;&quot;&gt;a&lt;/span&gt;.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;i&lt;/span&gt; = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; hasNext()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&quot;color: #0000d0;&quot;&gt;a&lt;/span&gt;.size());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E next() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; NoSuchElementException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;a&lt;/span&gt;.isEmpty())&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; NoSuchElementException(&lt;/span&gt;&quot;Array vuoto! next() non possibile&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;a&lt;/span&gt;.get(&lt;span style=&quot;color: #0000d0;&quot;&gt;i&lt;/span&gt;++);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; remove() {&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; TestIteratorAndPositions {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; main(String[] args) {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayIndexList&amp;lt;Integer&amp;gt; l = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayIndexList&amp;lt;Integer&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayIndexSequence&amp;lt;Integer&amp;gt; s = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayIndexSequence&amp;lt;Integer&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NodeSequence&amp;lt;Integer&amp;gt; s2 = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodeSequence&amp;lt;Integer&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NodePositionList&amp;lt;Integer&amp;gt; l2 = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Integer&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=1; i&amp;lt;=10; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;l2.addLast(i*4);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(l2);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Integer&amp;gt; iter = l2.iterator();&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.println(&lt;/span&gt;&quot;Stampa NodePositionList con iterator()&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(iter.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.print(iter.next()+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterable&amp;lt;Position&amp;lt;Integer&amp;gt;&amp;gt; posIt = l2.positions();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Position&amp;lt;Integer&amp;gt;&amp;gt; posIterator = posIt.iterator();&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.println(&lt;/span&gt;&quot;\nStampa NodePositionList con positions()&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(posIterator.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.print(posIterator.next() + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;10; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s.add(i, (i+1)*2);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;\n\n&quot;&lt;/span&gt;+s);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Iterator&amp;lt;Integer&amp;gt; it = (IndexListIterator&amp;lt;Integer&amp;gt;) s.iterator();&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.println(&lt;/span&gt;&quot;Stampa sequenza con iterator()&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.print(it.next() + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;posIt = s.positions();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;posIterator = posIt.iterator();&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.println(&lt;/span&gt;&quot;\nStampa sequenza con positions()&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(posIterator.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.print(posIterator.next() + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;10; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s2.add(i, (i+1)*5);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;\n\n&quot;&lt;/span&gt;+s2);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;it = (Iterator&amp;lt;Integer&amp;gt;) s2.iterator();&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.println(&lt;/span&gt;&quot;Stampa sequenza con iterator()&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.print(it.next() + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;posIt = s2.positions();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;posIterator = posIt.iterator();&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.println(&lt;/span&gt;&quot;\nStampa sequenza con positions()&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(posIterator.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.print(posIterator.next() + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;10; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;l.add(i, (i+1)*3);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;\n\n&quot;&lt;/span&gt;+l);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;it = (IndexListIterator&amp;lt;Integer&amp;gt;) l.iterator();&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.println(&lt;/span&gt;&quot;Stampa lista con iterator()&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(it.hasNext())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.print(it.next() + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;span class=&quot;fullpost&quot;&gt; &lt;br /&gt;
&lt;/span&gt; &lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/04/strutture-dati-iterator-e-positions.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-6126535152017626178</guid><pubDate>Wed, 06 Apr 2011 23:38:00 +0000</pubDate><atom:updated>2011-04-12T19:47:26.465+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MiaSequenzaIncompleta</category><category domain="http://www.blogger.com/atom/ns#">prova</category><category domain="http://www.blogger.com/atom/ns#">SequenzaIncompleta</category><category domain="http://www.blogger.com/atom/ns#">Strutture Dati</category><title>Prova del 5 Aprile 2011</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
Questa è l&#39;implementazione della mini-prova di Strutture Dati fatta dal prof La Torre il 5 Aprile 2011. Nella prima parte dell&#39;esercizio veniva fornita un&#39;interfaccia SequenzaIncompleta, e veniva chiesto di implementarne i metodi nella classe MiaSequenzaIncompleta usando a scelta una delle classi sviluppate durante il corso che implementano l&#39;interfaccia Sequence (completa). Nella seconda parte veniva fornita una classe di Test per MiaSequenzaIncompleta dove veniva chiesto di scrivere una funzione che prende in input una Sequenza e la inverte.&lt;/div&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;interface&lt;/span&gt; SequenzaIncompleta&amp;lt;E&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; addFirst(E e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;E removeLast();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E get(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; first();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; MiaSequenzaIncompleta&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; SequenzaIncompleta&amp;lt;E&amp;gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; ArrayIndexSequence&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;sequenza&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//private NodeSequence&amp;lt;E&amp;gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; MiaSequenzaIncompleta()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;sequenza&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayIndexSequence&amp;lt;E&amp;gt;();&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt; = new NodeSequence&amp;lt;E&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; addFirst(E e)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;sequenza&lt;/span&gt;.addFirst(e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; first()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;sequenza&lt;/span&gt;.first();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E get(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;sequenza&lt;/span&gt;.get(i);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E removeLast() {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;sequenza&lt;/span&gt;.removeLast();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size() {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;sequenza&lt;/span&gt;.size();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; TestSequenzaIncompleta&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; main(String[] args)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;SequenzaIncompleta&amp;lt;Integer&amp;gt; s = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; MiaSequenzaIncompleta&amp;lt;Integer&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=10; i&amp;gt;0 ; i--)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s.addFirst(i);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Sequenza iniziale&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stampa(s);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Sequenza invertita&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;inverti(s);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; stampa(s);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Rimuovi ultimo&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stampa(s);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Elemento rimosso =&quot;&lt;/span&gt;+ s.removeLast());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Primo elemento =&quot;&lt;/span&gt;+ s.first().element());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Inverti di nuovo&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;inverti(s);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stampa(s);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; stampa(SequenzaIncompleta&amp;lt;E&amp;gt; S){&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;S.size() ; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.print(S.get(i)+ &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;\n&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; inverti(SequenzaIncompleta&amp;lt;E&amp;gt; S)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; n = S.size();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; count = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=1; i&amp;lt;n; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;S.addFirst(S.get(i+count));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;count++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=1; i&amp;lt;n; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;S.removeLast();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;soluzione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;del&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;prof&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &lt;/span&gt;/* private static &amp;lt;E&amp;gt; void &lt;span style=&quot;text-decoration: underline;&quot;&gt;inverti&lt;/span&gt;(SequenzaIncompleta&amp;lt;E&amp;gt; S)&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; {&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;text-decoration: underline;&quot;&gt;int&lt;/span&gt; size = S.size();&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(&lt;span style=&quot;text-decoration: underline;&quot;&gt;int&lt;/span&gt; i=1; i&amp;lt;size; i++) S.addFirst(S.get(2*i-1));&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(&lt;span style=&quot;text-decoration: underline;&quot;&gt;int&lt;/span&gt; i=1; i&amp;lt;size; i++) S.removeLast();&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; */&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/04/prova-del-5-aprile-2011.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-4378177703189271450</guid><pubDate>Wed, 06 Apr 2011 23:00:00 +0000</pubDate><atom:updated>2011-04-12T19:41:39.691+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ArrayIndexSequence</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">NodeSequence</category><category domain="http://www.blogger.com/atom/ns#">Sequence</category><category domain="http://www.blogger.com/atom/ns#">Strutture Dati</category><title>Strutture Dati - Sequence</title><description>&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;Questo è il quarto post sulle Strutture Dati, vedremo le Interfacce e le Implementazioni del TDA Sequence mediante NodePositionList (NodeSequence), e ArrayIndexList (ArrayIndexSequence), entrambe viste nell&#39;articolo &lt;a href=&quot;http://emdief.blogspot.com/2011/03/strutture-dati-arraylist-e-nodelist.html&quot;&gt;precedente&lt;/a&gt;. Raccomando la lettura di questo post agli studenti dell&#39;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;a href=&quot;http://www.unisa.it/&quot; style=&quot;color: #445566;&quot;&gt;Università degli studi di Salerno&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;che studiano Informatica o Informatica Applicata e devono sostenere l&#39;esame di&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;a href=&quot;http://www.dia.unisa.it/professori/latorre/didattica/SD/&quot; style=&quot;color: #445566;&quot;&gt;Strutture Dati&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;(SD) o di Laboratorio di Algoritmi e Strutture Dati (LASD) con il professor&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;a href=&quot;http://www.dia.unisa.it/professori/latorre/&quot; style=&quot;color: #445566;&quot;&gt;Salvatore La Torre&lt;/a&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;.&amp;nbsp;Invito i miei colleghi studenti a desistere dalla tentazione di presentarvi all&#39;esame con i miei esercizi, (che per quanto io possa essere sicuro che siano corretti potrebbero comunque contenere errori) ma al massimo di usarli per confrontarli con i vostri.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Trebuchet MS&#39;, Verdana, Arial, sans-serif; font-size: 13px; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;interface&lt;/span&gt;&amp;nbsp;Sequence&amp;lt;E&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;extends&lt;/span&gt;&amp;nbsp;PositionList&amp;lt;E&amp;gt;, IndexList&amp;lt;E&amp;gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;Position&amp;lt;E&amp;gt; atIndex(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;BoundaryViolationException;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;indexOf(Position&amp;lt;E&amp;gt; p)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;InvalidPositionException;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E getFirst()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E getLast()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E removeFirst()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E removeLast()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt;&amp;nbsp;NodeSequence&amp;lt;E&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;extends&lt;/span&gt;&amp;nbsp;NodePositionList&amp;lt;E&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt;&amp;nbsp;Sequence&amp;lt;E&amp;gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;NodeSequence()&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;super&lt;/span&gt;();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt;&amp;nbsp;checkIndex(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;index,&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;n)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(index &amp;lt; 0 || index &amp;gt;= n)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;BoundaryViolationException (&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Indice &quot;&lt;/span&gt;&amp;nbsp;+ index +&amp;nbsp;&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; non valido&quot;&lt;/span&gt;);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E get(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i, size());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;(atIndex(i).element());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E set(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i, E e)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i, size());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;set(atIndex(i), e);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt;&amp;nbsp;add(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i, E e)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(i==size())&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;addLast(e);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;addBefore(atIndex(i), e);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E remove(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i, size());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;remove(atIndex(i));&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E getFirst()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;get(indexOf(first()));&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E getLast()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;get(indexOf(last()));&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E removeFirst()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(isEmpty())&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;EmptySequenceException();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;remove(indexOf(first()));&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E removeLast()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(isEmpty())&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;EmptySequenceException();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;remove(indexOf(last()));&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;Position&amp;lt;E&amp;gt; atIndex(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,size());&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; node;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(i &amp;lt;= size()/2)&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;node = (DNode&amp;lt;E&amp;gt;) first();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j=0; j &amp;lt; i; j++)&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;node = node.getNext();&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;node = (DNode&amp;lt;E&amp;gt;) last();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j=1; j &amp;lt; size()-i; j++)&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;node = node.getPrev();&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;node;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;indexOf(Position&amp;lt;E&amp;gt; p)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; nodo = checkPosition(p);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; aNode = (DNode&amp;lt;E&amp;gt;) first();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;index = 0;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(aNode != nodo)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;index++;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;aNode = aNode.getNext();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;index;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;String toString()&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String stringa =&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;super&lt;/span&gt;.toString();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringa = (String) stringa.subSequence(stringa.indexOf(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;), stringa.length());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringa =&amp;nbsp;&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;NodeSequence&quot;&lt;/span&gt;+ stringa;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;stringa;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt;&amp;nbsp;makeFirst(Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; node = checkPosition(p);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;node.getPrev().setNext(node.getNext());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;node.getNext().setPrev(node.getPrev());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;node.setNext(&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getNext());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;node.setPrev(&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;node.getNext().setPrev(node);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.setNext(node);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; ArraySequence&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; Sequence&amp;lt;E&amp;gt;, Iterable&amp;lt;E&amp;gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;final&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;static&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;CAPACITY&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; = 1024;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; ArrayPosition&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[];&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;size&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;f&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;costruttori&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; ArraySequence()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;CAPACITY&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #777777; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;@SuppressWarnings&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;unchecked&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; ArraySequence(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; cap)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt; = cap;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayPosition[&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; = &lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt; = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;==0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; first() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptySequenceException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(0)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E getFirst() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptySequenceException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; first().element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; last() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptySequenceException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E getLast() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptySequenceException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; last().element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E get(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i, &lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)].element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; checkIndex(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i, &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; n) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (i&amp;lt;0 || i&amp;gt;n)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; IndexOutOfBoundsException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; ArrayPosition&amp;lt;E&amp;gt; checkPosition (Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (p == &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;) &lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;null position&quot;&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;try&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; temp = (ArrayPosition&amp;lt;E&amp;gt;) p;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; flag = &lt;span style=&quot;color: #a10068;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)].equals(temp))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;flag = &lt;span style=&quot;color: #a10068;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (flag)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; temp;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; InvalidPositionException(&lt;/span&gt;&quot;This element does not belog to this sequence&quot;&lt;span style=&quot;color: black;&quot;&gt;);&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;catch&lt;/span&gt; (ClassCastException e)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;not an ArrayPosition&quot;&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; prev(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException, BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(tmp.equals(first()))&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;No Positions before the first&quot;&lt;/span&gt;);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; index = tmp.getIndex()-1;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(index)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; next(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException, BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(tmp.equals(last()))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;No Positions after the last&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; index = tmp.getIndex()+1;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(index)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; add(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (size() == &lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #777777; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;@SuppressWarnings&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;unchecked&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp[] = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayPosition[&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;*2];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=0; j&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;;j++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;tmp[j] = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt; = tmp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt; *=2;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt;=&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;-1;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; newElem = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayPosition&amp;lt;E&amp;gt;(i,e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(i==0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt;]=newElem;&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;f&lt;span style=&quot;color: black;&quot;&gt;=(&lt;/span&gt;f&lt;span style=&quot;color: black;&quot;&gt;-1+&lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;)%&lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(i&amp;gt;0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j= &lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1; j&amp;gt;= i; j--)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j+1)] = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j+1)].setIndex(j+1);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)] = newElem;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;aggiorno&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;gli&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;indici&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=size()-1; j &amp;gt;= i; j--)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;tmp.setIndex(j);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; addBefore(Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i = indexOf(tmp);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(i,e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; prev(tmp);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; addAfter (Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i = indexOf(tmp)+1;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(i, e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; next(tmp);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; addFirst(E e)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(0,e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; addLast(E e)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;,e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E remove(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; remove(indexOf(p));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E remove(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E e = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)].element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(i==0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt;=(&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt;+1)%&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j = i; j&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1; j++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j)] = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j+1)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;--;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=size()-1; j &amp;gt;= i; j--)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;tmp.setIndex(j);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;size&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;&lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;/3)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #777777; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;@SuppressWarnings&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;unchecked&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; nuovoArray[] = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayPosition[&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;/2];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=0; j&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;; j++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;nuovoArray[j] = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt; = nuovoArray;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt; /= 2;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt; = &lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;-1;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; e;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E removeFirst() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; remove(0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E removeLast() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; remove(&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E set(Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; set(indexOf(tmp),e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E set(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; newEl = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayPosition&amp;lt;E&amp;gt;(i,e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)] = newEl;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; e;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; atIndex(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;try&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;checkIndex(i, size());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;catch&lt;/span&gt;(IndexOutOfBoundsException e)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; BoundaryViolationException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;atIndex non possibile.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)];&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; indexOf(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp.getIndex();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;public&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; map(&lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; i)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;(i+&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt;+1)%&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterator&amp;lt;E&amp;gt; iterator()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ElementIterator&amp;lt;E&amp;gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;this&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterable&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; positions()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; tmp =&amp;nbsp; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArraySequence&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt;();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;tmp.addLast(&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)]);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String retVal = &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;[ &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;size(); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;retVal += &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)] +&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;retVal += &lt;/span&gt;&quot;] size:&quot;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&quot; capacity:&quot;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; retVal;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt;&amp;nbsp;ArrayIndexSequence&amp;lt;E&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt;&amp;nbsp;Sequence&amp;lt;E&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt;&amp;nbsp;ArrayIndexList&amp;lt;ArrayPosition&amp;lt;E&amp;gt;&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt;&amp;nbsp;makeFirst(Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkPosition(p);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp = remove(p);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;addFirst(tmp);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;ArrayIndexSequence()&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;ArrayIndexList&amp;lt;ArrayPosition&amp;lt;E&amp;gt;&amp;gt;();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;ArrayIndexSequence(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;cap)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;ArrayIndexList&amp;lt;ArrayPosition&amp;lt;E&amp;gt;&amp;gt;(cap);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;size()&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt;&amp;nbsp;isEmpty()&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.isEmpty();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;Position&amp;lt;E&amp;gt; first()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(isEmpty())&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;EmptySequenceException();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(0);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;Position&amp;lt;E&amp;gt; last()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(isEmpty())&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;EmptySequenceException();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size()-1);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E getFirst()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;first().element();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E getLast()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;last().element();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;Position&amp;lt;E&amp;gt; prev(Position&amp;lt;E&amp;gt; p)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;InvalidPositionException, BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(indexOf(tmp)-1);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;Position&amp;lt;E&amp;gt; next(Position&amp;lt;E&amp;gt; p)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;InvalidPositionException,BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(indexOf(tmp)+1);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt;&amp;nbsp;add(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i, E e)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; newElement =&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;ArrayPosition&amp;lt;E&amp;gt;(i,e);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.add(i,newElement);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;aggiorno&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;gli&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;indici&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j=&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size()-1; j &amp;gt;= i; j--)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(j).setIndex(j);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;Position&amp;lt;E&amp;gt; addBefore(Position&amp;lt;E&amp;gt; p, E e)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i = indexOf(tmp);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(i,e);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(i);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;Position&amp;lt;E&amp;gt; addAfter(Position&amp;lt;E&amp;gt; p, E e)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i = indexOf(tmp)+1;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(i, e);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(i);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt;&amp;nbsp;addFirst(E e)&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(0, e);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt;&amp;nbsp;addLast(E e)&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size(), e);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E set(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i, E e)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; newElement =&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;ArrayPosition&amp;lt;E&amp;gt;(i,e);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.set(i,newElement).element();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;e;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E set(Position&amp;lt;E&amp;gt; p, E e)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; newElement = checkPosition(p);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;newElement.setElement(e);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.set(indexOf(p), newElement).element();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E get(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(i).element();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E remove(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(isEmpty())&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;EmptySequenceException();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp =&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.remove(i).element();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;aggiorno&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;gli&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;indici&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;j=&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size()-1; j &amp;gt;= i; j--)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(j).setIndex(j);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;tmp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E remove(Position&amp;lt;E&amp;gt; p)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp =remove(indexOf(p));&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;tmp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E removeFirst()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp = remove(0);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;tmp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;E removeLast()&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;EmptySequenceException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp = remove(&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size()-1);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;tmp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;Position&amp;lt;E&amp;gt; atIndex(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(i);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;indexOf(Position&amp;lt;E&amp;gt; p)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;try&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; tmp = (ArrayPosition&amp;lt;E&amp;gt;)p;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;tmp.getIndex();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;catch&lt;/span&gt;(InvalidPositionException e)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;-1;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt;&amp;nbsp;ArrayPosition&amp;lt;E&amp;gt; checkPosition(Position&amp;lt;E&amp;gt; p)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;InvalidPositionException&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(p ==&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;null position&quot;&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;try&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ArrayPosition&amp;lt;E&amp;gt; temp = (ArrayPosition&amp;lt;E&amp;gt;) p;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(indexOf(temp)&amp;lt;0)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;InvalidPositionException();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;temp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;catch&lt;/span&gt;&amp;nbsp;(ClassCastException e)&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;InvalidPositionException(&lt;/span&gt;&quot;Cast Error: it&#39;s not an ArrayPosition&quot;&lt;span style=&quot;color: black;&quot;&gt;);&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt;&amp;nbsp;checkIndex(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;i,&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&amp;nbsp;n)&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt;&amp;nbsp;BoundaryViolationException&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(i&amp;lt;0 || i&amp;gt;n)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt;&amp;nbsp;BoundaryViolationException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Indice &quot;&lt;/span&gt;+i+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; non valido&quot;&lt;/span&gt;);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;String toString()&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;ArrayIndexSequence [&quot;&lt;/span&gt;+&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.toString().subSequence(&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.toString().indexOf(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;),&amp;nbsp;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.toString().length());&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public&lt;/span&gt; Iterator&amp;lt;E&amp;gt; iterator()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; IndexListIterator&amp;lt;E&amp;gt;((IndexList&amp;lt;E&amp;gt;) &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterable&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; positions()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;IndexList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; tmp =&amp;nbsp; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayIndexList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.size(); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;tmp.add(i, &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;.get(i));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;/*&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Scrivere&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;funzione&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ricorsiva&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; boolean search(Sequence&amp;lt;E&amp;gt;S, E x)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;che&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;restituisce&lt;/span&gt;&amp;nbsp;true&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt;&amp;nbsp;S&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;contiene&lt;/span&gt;&amp;nbsp;l’elemento x.&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Definizione&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ricorsiva&lt;/span&gt;: search(&amp;lt;s1,...,&lt;span style=&quot;text-decoration: underline;&quot;&gt;sn&lt;/span&gt;&amp;gt;, x)&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;restituisce&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; false,&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt;&amp;nbsp;n=0&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; true,&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt;&amp;nbsp;s1=x&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Il&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;valore&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;restituito&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;da&lt;/span&gt;&amp;nbsp;search(&amp;lt;s2,...,&lt;span style=&quot;text-decoration: underline;&quot;&gt;sn&lt;/span&gt;&amp;gt;, x),&amp;nbsp;&lt;span style=&quot;text-decoration: underline;&quot;&gt;altrimenti&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;*/&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt;&amp;nbsp;&amp;lt;E&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt;&amp;nbsp;search(Sequence&amp;lt;E&amp;gt; S, E x)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(S.size()==0)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;false&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(S.get(0).equals(x))&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;true&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp = S.removeFirst();&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt;&amp;nbsp;ris = search(S, x);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;S.addFirst(tmp);&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&amp;nbsp;ris;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;/span&gt;&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
Questa è l&#39;implementazione di ArraySequence di Valerio, che ringrazio per le correzioni al mio codice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;* &lt;span style=&quot;text-decoration: underline;&quot;&gt;Implementazione&lt;/span&gt; dell&#39;interfaccia Sequence &lt;span style=&quot;text-decoration: underline;&quot;&gt;mediante&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;* &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; array &lt;span style=&quot;text-decoration: underline;&quot;&gt;circolare&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ed&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;estendibile&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; ArrayPosition.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;*&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;* &lt;span style=&quot;color: #89afcc;&quot;&gt;@see&lt;/span&gt; EmptyListException&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;* &lt;span style=&quot;color: #89afcc;&quot;&gt;@see&lt;/span&gt; EmptySequenceException&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;* &lt;span style=&quot;color: #89afcc;&quot;&gt;@see&lt;/span&gt; IndexOutOfBoundsException&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;* &lt;span style=&quot;color: #89afcc;&quot;&gt;@see&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&amp;nbsp;*/&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; ArraySequence&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;Sequence&lt;/span&gt;&amp;lt;E&amp;gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;// Array &lt;span style=&quot;text-decoration: underline;&quot;&gt;circolare&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;contenente&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;S&lt;/span&gt;[];&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;// &lt;span style=&quot;text-decoration: underline;&quot;&gt;Indice&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;della&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;prima&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;posizione&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;first&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; = 0;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;// &lt;span style=&quot;text-decoration: underline;&quot;&gt;Indice&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;della&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;prima&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;posizione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;libera&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;dopo&lt;/span&gt; l&#39;ultimo &lt;span style=&quot;text-decoration: underline;&quot;&gt;elemento&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;last&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; = 0;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;// &lt;span style=&quot;text-decoration: underline;&quot;&gt;Capacit&lt;/span&gt;‡ dell&#39;array.&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;// &lt;span style=&quot;text-decoration: underline;&quot;&gt;Capacit&lt;/span&gt;‡ &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; default dell&#39;array.&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;public&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;static&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;final&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;CAPACITY&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; = 1024;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Costruttore&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; default.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; ArraySequence() {&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;CAPACITY&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Inizializza&lt;/span&gt; l&#39;array &lt;span style=&quot;text-decoration: underline;&quot;&gt;con&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;una&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;grandezza&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;specificata&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; cap&amp;nbsp; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;lunghezza&lt;/span&gt; dell&#39;array&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;color: #777777; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;@SuppressWarnings&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;unchecked&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; ArraySequence(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; cap) {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt; = cap;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Restituisce&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;numero&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;posizioni&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;della&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;numero&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;posizioni&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size() {&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;-&lt;/span&gt;first&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;last&lt;span style=&quot;color: black;&quot;&gt;) % &lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Verifica&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt; Ë &lt;span style=&quot;text-decoration: underline;&quot;&gt;vuota&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; true &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt; Ë &lt;span style=&quot;text-decoration: underline;&quot;&gt;vuota&lt;/span&gt;, false &lt;span style=&quot;text-decoration: underline;&quot;&gt;altrimenti&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty() {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;first&lt;/span&gt; == &lt;span style=&quot;color: #0000d0;&quot;&gt;last&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Restituisce&lt;/span&gt; l&#39;elemento &lt;span style=&quot;text-decoration: underline;&quot;&gt;della&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;prima&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;posizione&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;primo&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elemento&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; EmptySequenceException&amp;nbsp; &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt; Ë &lt;span style=&quot;text-decoration: underline;&quot;&gt;vuota&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E getFirst() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;EmptySequenceException&lt;/span&gt; {&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;first&lt;/span&gt;().element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Restituisce&lt;/span&gt; l&#39;elemento dell&#39;ultima &lt;span style=&quot;text-decoration: underline;&quot;&gt;posizione&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;ultimo &lt;span style=&quot;text-decoration: underline;&quot;&gt;elemento&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; EmptySequenceException&amp;nbsp; &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt; Ë &lt;span style=&quot;text-decoration: underline;&quot;&gt;vuota&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E getLast() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;EmptySequenceException&lt;/span&gt; {&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;last&lt;/span&gt;().element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Inserisce&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;una&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nuova&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;posizione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;con&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elemento&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;dato&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * all&#39;inizio &lt;span style=&quot;text-decoration: underline;&quot;&gt;della&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; element&amp;nbsp; l&#39;elemento &lt;span style=&quot;text-decoration: underline;&quot;&gt;da&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;memorizzare&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nella&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nuova&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;posizione&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; addFirst(E elem) {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(0, elem);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Inserisce&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;una&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nuova&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;posizione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;con&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elemento&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;dato&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;alla&lt;/span&gt; fine &lt;span style=&quot;text-decoration: underline;&quot;&gt;della&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;sequenza&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; element&amp;nbsp; l&#39;elemento &lt;span style=&quot;text-decoration: underline;&quot;&gt;da&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;memorizzare&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;nella&lt;/span&gt; nuova posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; addLast(E elem) {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(size(), elem);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Rimuove la prima posizione della sequenza e&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * restituisce l&#39;elemento memorizzato in essa.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;elemento memorizzato&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; EmptySequenceException&amp;nbsp; se la sequenza Ë vuota&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E removeFirst() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;EmptySequenceException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; remove(0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Rimuove l&#39;ultima posizione della sequenza e&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * restituisce l&#39;elemento memorizzato in essa.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;elemento memorizzato&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; EmptySequenceException&amp;nbsp; se la sequenza Ë vuota&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E removeLast() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;EmptySequenceException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; remove(size() - 1);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Restituisce la prima posizione della sequenza.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la prima posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; EmptySequenceException&amp;nbsp; se la sequenza Ë vuota&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; first() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;EmptySequenceException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;EmptySequenceException&lt;/span&gt;();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;first&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Restituisce l&#39;ultima posizione della sequenza.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;ultima posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; EmptySequenceException&amp;nbsp; se la sequenza Ë vuota&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; last() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;EmptySequenceException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;EmptySequenceException&lt;/span&gt;();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(size()-1)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Restituisce la posizione precedente a quella data.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione di partenza&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione precedente&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; InvalidPositionException&amp;nbsp; &amp;nbsp; se la posizione non Ë valida&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; BoundaryViolationException&amp;nbsp; se fuori range&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; prev(Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt;, &lt;span style=&quot;text-decoration: underline;&quot;&gt;BoundaryViolationException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; pos = &lt;span style=&quot;text-decoration: underline;&quot;&gt;checkPosition&lt;/span&gt;(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(indexOf(pos), size());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (pos.equals(&lt;span style=&quot;text-decoration: underline;&quot;&gt;first&lt;/span&gt;()))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;BoundaryViolationException&lt;/span&gt;(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Nessuna posizione prima del primo.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; atIndex(indexOf(pos) - 1);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Restituisce la posizione successiva a quella data.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione di partenza&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione successiva&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; InvalidPositionException&amp;nbsp; &amp;nbsp; se la posizione non Ë valida&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; BoundaryViolationException&amp;nbsp; se fuori range&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; next(Position&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt;, &lt;span style=&quot;text-decoration: underline;&quot;&gt;BoundaryViolationException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; pos = &lt;span style=&quot;text-decoration: underline;&quot;&gt;checkPosition&lt;/span&gt;(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(indexOf(pos), size());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (pos.equals(&lt;span style=&quot;text-decoration: underline;&quot;&gt;last&lt;/span&gt;()))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;BoundaryViolationException&lt;/span&gt;(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Nessuna posizione dopo l&#39;ultimo.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; atIndex(indexOf(pos) + 1);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Inserisce una nuova posizione con elemento dato&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * prima la posizione specificata.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione che deve succedere&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; elem &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;elemento da memorizzare&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la nuova posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; InvalidPositionException&amp;nbsp; se la posizione non Ë valida&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; addBefore(Position&amp;lt;E&amp;gt; p, E elem) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; pos = &lt;span style=&quot;text-decoration: underline;&quot;&gt;checkPosition&lt;/span&gt;(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i = indexOf(pos);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(i, elem);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; prev(pos);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Inserisce una nuova posizione con elemento dato&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * dopo la posizione specificata.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione che deve precedere&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; elem &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;elemento da memorizzare&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la nuova posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; InvalidPositionException&amp;nbsp; se la posizione non Ë valida&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; addAfter(Position&amp;lt;E&amp;gt; p, E elem) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; pos = &lt;span style=&quot;text-decoration: underline;&quot;&gt;checkPosition&lt;/span&gt;(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i = indexOf(pos) + 1;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;add(i, elem);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; next(pos);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Rimuove la posizione data e restituisce l&#39;elemento&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * in essa memorizzato.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione da rimuovere&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;elemento memorizzato&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; InvalidPositionException&amp;nbsp; se la posizione non Ë valida&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E remove(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; pos = &lt;span style=&quot;text-decoration: underline;&quot;&gt;checkPosition&lt;/span&gt;(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; remove(indexOf(pos));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Rimpiazza l&#39;elemento memorizzato nella posizione data&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * con un nuovo elemento e lo restituisce.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione in cui rimpiazzare l&#39;elemento&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; elem &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; il nuovo elemento da settare&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; il vecchio elemento&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; InvalidPositionException&amp;nbsp; se la posizione non Ë valida&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E set(Position&amp;lt;E&amp;gt; p, E elem) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; pos = &lt;span style=&quot;text-decoration: underline;&quot;&gt;checkPosition&lt;/span&gt;(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E oldElem = pos.element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;pos.setElement(elem);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; oldElem;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Restituisce l&#39;elemento della posizione di indice dato.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; index &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;indice della posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;elemento della posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp; se fuori range&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E get(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; index) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(index, size());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;atIndex&lt;/span&gt;(index).element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Rimpiazza l&#39;elemento della posizione di indice dato&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * con un nuovo elemento e restituisce il vecchio elemento.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; index &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;indice della posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; elem&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; il nuovo elemento&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; il vecchio elemento&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp; se fuori range&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E set(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; index, E elem) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(index, size());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; pos = &lt;span style=&quot;text-decoration: underline;&quot;&gt;(ArrayPosition&amp;lt;E&amp;gt;) atIndex(index)&lt;/span&gt;;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; set(pos, elem);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Inserisce una nuova posizione di indice specificato.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; index &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;indice della posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; elem&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;elemento da memorizzare&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp; se fuori range&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; add(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; index, E elem) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(index, size());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (size() == &lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;-1)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;raddoppia();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; newPos = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt;(index, elem);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (index == 0) {&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;first&lt;span style=&quot;color: black;&quot;&gt; = (&lt;/span&gt;first&lt;span style=&quot;color: black;&quot;&gt;-1+&lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;) % &lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;first&lt;/span&gt;] = newPos;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;// Aggiorno gli indici&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=1; j&amp;lt;size(); j++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(j)].setIndex(j);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;else&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=size()-1; j&amp;gt;=index; j--) {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(j+1)] = &lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(j)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(j+1)].setIndex(j+1);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(index)] = newPos;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;last&lt;/span&gt; = (&lt;span style=&quot;color: #0000d0;&quot;&gt;last&lt;/span&gt; + 1) % &lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Rimuove la posizione di indice dato e ne restituisce l&#39;elemento.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; index &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;indice della posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;elemento memorizzato&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp; se fuori range&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E remove(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; index) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(index, size());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E elem = &lt;span style=&quot;text-decoration: underline;&quot;&gt;atIndex&lt;/span&gt;(index).element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (index == 0) {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;first&lt;/span&gt;] = &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;first&lt;span style=&quot;color: black;&quot;&gt; = (&lt;/span&gt;first&lt;span style=&quot;color: black;&quot;&gt;+1) % &lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;// Vengono aggiornati gli indici.&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=0; j&amp;lt;size(); j++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(j)].setIndex(j);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;else&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;last&lt;span style=&quot;color: black;&quot;&gt; = (&lt;/span&gt;last&lt;span style=&quot;color: black;&quot;&gt;-1+&lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;) % &lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;// Gli elementi vengono shiftati a sinistra&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;// e vengono aggiornati gli indici.&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; h=index; h&amp;lt;size(); h++) {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(h)] = &lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(h+1)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(h)].setIndex(h);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; elem;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Restituisce una rappresentazione testuale di un ArraySequence&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * come una lista di elementi: [primo, secondo, ... , ultimo].&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; una rappresentazione testuale della lista&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString() {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String s = &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;[&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (size() &amp;gt; 0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s += get(i);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (size() &amp;gt; 1)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (i=1; i&amp;lt;size(); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;s += &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;, &quot;&lt;/span&gt; + get(i);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;s += &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;]&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; s;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Metodo di servizio che controlla che l&#39;indice sia nel range [0, n&lt;span style=&quot;color: #9191b0;&quot;&gt;-&lt;/span&gt;1].&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; index &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;indice da controllare&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; n &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; il valore del range&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp; se indice &amp;lt; 0 oppure indice &amp;gt; n&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; checkIndex(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; index, &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; n) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException {&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (index &amp;lt; 0 || index &amp;gt; n)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; IndexOutOfBoundsException (&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Líindice &quot;&lt;/span&gt; +index+&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;&quot; non Ë valido per questa sequenza.&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Metodo di servizio che controlla se la posizione Ë valida&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * per questa sequenza e la converte in ArrayPosition in caso positivo.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione da controllare&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione convertita nel tipo ArrayPosition&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; InvalidPositionException&amp;nbsp; se la posizione non Ë valida&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; checkPosition(Position&amp;lt;E&amp;gt; p)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (p == &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt;(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Posizione nulla.&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;try&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; pos = &lt;span style=&quot;text-decoration: underline;&quot;&gt;(ArrayPosition&amp;lt;E&amp;gt;) p&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; pos;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;catch&lt;/span&gt; (ClassCastException e) {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Restituisce la posizione dell&#39;elemento con indice dato.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; index&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;indice dell&#39;elemento&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione dell&#39;elemento&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; BoundaryViolationException&amp;nbsp; se fuori range&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; atIndex(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; index) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;BoundaryViolationException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(index, size());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[map(index)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Restituisce l&#39;indice della posizione data.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; la posizione dell&#39;elemento&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;indice dell&#39;elemento&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; InvalidPositionException&amp;nbsp; se la posizione non Ë valida&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; indexOf(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; pos = &lt;span style=&quot;text-decoration: underline;&quot;&gt;checkPosition&lt;/span&gt;(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; pos.getIndex();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Metodo di servizio che raddoppia la capacit‡&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * dell&#39;array in caso non vi siano pi˘ posti liberi.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;color: #777777; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;@SuppressWarnings&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;unchecked&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; raddoppia() {&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;// Numero di elementi nell&#39;array prima di&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;// modificare il valore di capacity&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; numElem = size();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; oldCap = &lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt; *= 2;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; S2[] = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;// Gli elementi vengono copiati nel nuovo array&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;// ponendo il first a partire da 0 e scorrendo il&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;// vecchio array dal first in poi&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i,j;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (i=0,j=&lt;span style=&quot;color: #0000d0;&quot;&gt;first&lt;/span&gt;; i&amp;lt;numElem; i++,j=(j+1)%oldCap)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;S2[i] = &lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt;[j];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;// Nuovo valore del first&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;first&lt;/span&gt; = 0;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;// Nuovo valore del last&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;last&lt;/span&gt; = numElem;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;S&lt;/span&gt; = S2;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Metodo di servizio che restituisce l&#39;indice della posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * all&#39;interno dell&#39;array.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; index&amp;nbsp; l&#39;indice della posizione&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; l&#39;indice all&#39;interno dell&#39;array&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; map(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; index) {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;first&lt;/span&gt; + index) % &lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Sposta l&#39;elemento di posizione data all&#39;inizio della sequenza&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * lasciando inalterato l&#39;ordine dei rimanenti elementi.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; *&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; p&amp;nbsp; la posizione da spostare&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; makeFirst(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;InvalidPositionException&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;ArrayPosition&lt;/span&gt;&amp;lt;E&amp;gt; pos = &lt;span style=&quot;text-decoration: underline;&quot;&gt;checkPosition&lt;/span&gt;(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;addFirst(remove(pos));&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/04/strutture-dati-sequence.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>14</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-1041693066258692718</guid><pubDate>Fri, 25 Mar 2011 10:43:00 +0000</pubDate><atom:updated>2011-04-08T01:54:17.839+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">ArrayIndexList</category><category domain="http://www.blogger.com/atom/ns#">ArrayList</category><category domain="http://www.blogger.com/atom/ns#">IndexList</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">NodeList</category><category domain="http://www.blogger.com/atom/ns#">NodePositionList</category><category domain="http://www.blogger.com/atom/ns#">Position</category><category domain="http://www.blogger.com/atom/ns#">PositionList</category><category domain="http://www.blogger.com/atom/ns#">Strutture Dati</category><title>Strutture Dati - ArrayList e NodeList</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;Questo è il terzo post sulle Strutture Dati, in particolare oggi vedremo le Interfacce e le Implementazioni di TDA di tipo sequenza come ArrayList (si accede agli elementi attraverso il loro indice) e NodeList (dove il concetto principale e la Position). Raccomando la lettura di questo post agli studenti dell&#39;&lt;a href=&quot;http://www.unisa.it/&quot;&gt;Università degli studi di Salerno&lt;/a&gt; che studiano Informatica o Informatica Applicata e devono sostenere l&#39;esame di &lt;a href=&quot;http://www.dia.unisa.it/professori/latorre/didattica/SD/&quot;&gt;Strutture Dati&lt;/a&gt;&amp;nbsp;(SD) o di Laboratorio di Algoritmi e Strutture Dati (LASD) con il professor &lt;a href=&quot;http://www.dia.unisa.it/professori/latorre/&quot;&gt;Salvatore La Torre&lt;/a&gt;.&amp;nbsp;Invito i miei colleghi studenti a desistere dalla tentazione di presentarvi all&#39;esame con i miei esercizi, (che per quanto io possa essere sicuro che siano corretti potrebbero comunque contenere errori) ma al massimo di usarli per confrontarli con i vostri.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;hr /&gt;&lt;span class=&quot;fullpost&quot;&gt;Esercizi aggiornati al 8/04/2011 &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;h4&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;Codice per gli ArrayList&lt;/b&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;interface&lt;/span&gt; IndexList &amp;lt;E&amp;gt;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times; font-size: small;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;div style=&quot;display: inline !important; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;display: inline !important; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;extends&lt;/span&gt; Iterable&amp;lt;E&amp;gt;&lt;/div&gt;&lt;/div&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E get(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E set(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; add(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E remove(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty();&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.5px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;Implementare l’interfaccia &lt;span style=&quot;color: #006533;&quot;&gt;IndexList &lt;/span&gt;utilizzando un array (classe &lt;span style=&quot;color: #c00100;&quot;&gt;ArrayIndexList&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.5px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #cc9a02; font: normal normal normal 9.4px/normal Wingdings;&quot;&gt;􏰀􏰀 &lt;/span&gt;Scrivere un programma di test della classe &lt;span style=&quot;color: #c00100;&quot;&gt;ArrayIndexList&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.5px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #cc9a02; font: normal normal normal 9.4px/normal Wingdings;&quot;&gt;􏰀 &lt;/span&gt;Implementare l’interfaccia &lt;span style=&quot;color: #006533;&quot;&gt;Queue &lt;/span&gt;mediante i metodi di &lt;span style=&quot;color: #006533;&quot;&gt;IndexList &lt;/span&gt;(implementato dalla classe &lt;span style=&quot;color: #c00100;&quot;&gt;ArrayIndexList&lt;/span&gt;&lt;span style=&quot;color: #5f5e5f;&quot;&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #5f5e5f;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: small;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times;&quot;&gt;&lt;b&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;//ArrayIndexList &lt;span style=&quot;text-decoration: underline;&quot;&gt;implementato&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;con&lt;/span&gt; array &lt;span style=&quot;text-decoration: underline;&quot;&gt;circolare&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;estendibile&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; ArrayIndexList&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; IndexList&amp;lt;E&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;static&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;final&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;CAPACITY&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; = 1024;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;size&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;, &lt;/span&gt;f&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; E &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; ArrayIndexList()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;CAPACITY&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; ArrayIndexList(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; cap)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt; = cap;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt; = &lt;span style=&quot;text-decoration: underline;&quot;&gt;(E[])&lt;/span&gt;&lt;span style=&quot;color: #a10068; text-decoration: underline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt; Object[&lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;capacity&lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;]&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E get(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E set(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)] = e;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; add(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;size&lt;span style=&quot;color: black;&quot;&gt; == &lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;E nuovoArray[] = &lt;span style=&quot;text-decoration: underline;&quot;&gt;(E[]) &lt;/span&gt;&lt;span style=&quot;color: #a10068; text-decoration: underline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt; Object[&lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;capacity&lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;*2]&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=0; j&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;; j++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;nuovoArray[j] = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt; = nuovoArray;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt; *= 2;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt; = &lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;-1;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(i==0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt;] = e;&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;f&lt;span style=&quot;color: black;&quot;&gt; = (&lt;/span&gt;f&lt;span style=&quot;color: black;&quot;&gt;-1+&lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;)%&lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(i&amp;gt;0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1; j&amp;gt;= i; j--)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j+1)] = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)] = e;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E remove(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; IndexOutOfBoundsException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;checkIndex(i,&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmp = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(i == 0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt; = (&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt;+1)%&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=i; j&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1; j++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j)] = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j+1)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;--;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;size&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;&lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;/3)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;E nuovoArray[] = &lt;span style=&quot;text-decoration: underline;&quot;&gt;(E[]) &lt;/span&gt;&lt;span style=&quot;color: #a10068; text-decoration: underline;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt; Object[&lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;capacity&lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;/2]&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; j=0; j&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;; j++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;nuovoArray[j] = &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(j)];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt; = nuovoArray;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt; /= 2;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt; = &lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;-1;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; == 0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String stringa =&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;[ &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0;i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;;i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;stringa += &lt;span style=&quot;color: #0000d0;&quot;&gt;array&lt;/span&gt;[map(i)] + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringa += &lt;/span&gt;&quot;] size:&quot;&lt;span style=&quot;color: black;&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; + &lt;/span&gt;&quot; capacity:&quot;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&quot; f:&quot;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; stringa;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;public&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; map(&lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; i)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;f&lt;/span&gt;+i+1)%&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; checkIndex(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i,&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; n)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (i&amp;lt;0 || i&amp;gt;n)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; IndexOutOfBoundsException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;errore indice &quot;&lt;/span&gt;+i);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; IndexListQueue&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; Queue&amp;lt;E&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; ArrayIndexList&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;coda&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; IndexListQueue()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;coda&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayIndexList&amp;lt;E&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;coda&lt;/span&gt;.size();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;coda&lt;/span&gt;.isEmpty();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E front() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyQueueException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyQueueException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;coda&lt;/span&gt;.get(0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; enqueue(E element)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;coda&lt;/span&gt;.add(size(), element);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E dequeue() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyQueueException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyQueueException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;coda&lt;/span&gt;.remove(0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Queue with &quot;&lt;/span&gt;+&lt;span style=&quot;color: #0000d0;&quot;&gt;coda&lt;/span&gt;.toString();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.5px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;Implementare l’interfaccia &lt;span style=&quot;color: #006533;&quot;&gt;Deque &lt;/span&gt;mediante i metodi di &lt;span style=&quot;color: #006533;&quot;&gt;IndexList &lt;/span&gt;(implementato dalla classe &lt;span style=&quot;color: #c00100;&quot;&gt;ArrayIndexList&lt;/span&gt;&lt;span style=&quot;color: #5f5e5f;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.5px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #cc9a02; font: normal normal normal 9.4px/normal Wingdings;&quot;&gt;􏰀􏰀 &lt;/span&gt;Analizzare la complessità dei metodi di &lt;span style=&quot;color: #006533;&quot;&gt;Deque &lt;/span&gt;con questa implementazione&lt;/div&gt;&lt;div style=&quot;font: 14.5px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #cc9a02; font: normal normal normal 9.4px/normal Wingdings;&quot;&gt;􏰀 &lt;/span&gt;Modificare la classe &lt;span style=&quot;color: #c00100;&quot;&gt;ArrayIndexList &lt;/span&gt;in modo che i metodi addFirst e removeFirst di &lt;span style=&quot;color: #006533;&quot;&gt;Deque &lt;/span&gt;abbiano tempo di esecuzione O(1)&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; IndexListDeque&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; Deque&amp;lt;E&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;ArrayIndexList&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; IndexListDeque()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayIndexList&amp;lt;E&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.size();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.isEmpty();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E getFirst() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyDequeException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyDequeException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.get(0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E getLast() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyDequeException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyDequeException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.get(&lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.size()-1);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; addFirst(E element)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.add(0, element);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; addLast(E element)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.add(&lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.size()-1, element);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E removeFirst() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyDequeException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyDequeException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.remove(0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E removeLast() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyDequeException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;(isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyDequeException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.remove(&lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.size()-1);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Deque with &quot;&lt;/span&gt; + &lt;span style=&quot;color: #0000d0;&quot;&gt;dek&lt;/span&gt;.toString();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Codice su NodeList&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;interface&lt;/span&gt; Position &amp;lt;E&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; DNode&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; Position&amp;lt;E&amp;gt;, Comparable&amp;lt;E&amp;gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; E &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;element&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; DNode&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;prev&lt;/span&gt;, &lt;span style=&quot;color: #0000d0;&quot;&gt;next&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;idLista&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; &lt;/span&gt;//id &lt;span style=&quot;text-decoration: underline;&quot;&gt;Univoco&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;della&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;Lista&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; DNode()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;this&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;null&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;null&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;null&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; DNode(E e, DNode&amp;lt;E&amp;gt; p, DNode&amp;lt;E&amp;gt; n)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;element&lt;/span&gt; = e;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;prev&lt;/span&gt; = p;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;next&lt;/span&gt; = n;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;idLista&lt;/span&gt; = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; DNode(E e, DNode&amp;lt;E&amp;gt; p, DNode&amp;lt;E&amp;gt; n, &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; idlist)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;element&lt;/span&gt; = e;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;prev&lt;/span&gt; = p;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;next&lt;/span&gt; = n;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;idLista&lt;/span&gt; = idlist;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; getIdLista()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;idLista&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; setIdLista(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; id)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;idLista&lt;/span&gt; = id;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; DNode&amp;lt;E&amp;gt; getPrev()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;prev&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; DNode&amp;lt;E&amp;gt; getNext()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;metodi&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;modificatori&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; setElement(E e)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;element&lt;/span&gt; = e;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; setPrev(DNode&amp;lt;E&amp;gt; p)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;prev&lt;/span&gt; = p;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; setNext(DNode&amp;lt;E&amp;gt; n)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;next&lt;/span&gt; = n;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E element() {&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;element&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;element&lt;/span&gt;.toString();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; compareTo(E arg0)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Comparable&amp;lt;E&amp;gt; el = &lt;span style=&quot;text-decoration: underline;&quot;&gt;(Comparable&amp;lt;E&amp;gt;) &lt;/span&gt;&lt;span style=&quot;color: #0000d0; text-decoration: underline;&quot;&gt;element&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; el.compareTo(arg0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;u&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #a10068;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/u&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;interface&lt;/span&gt; PositionList&amp;lt;E&amp;gt;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times; font-size: small;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;div style=&quot;display: inline !important;&quot;&gt;&lt;div style=&quot;display: inline !important; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;display: inline !important; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;extends&lt;/span&gt; Iterable&amp;lt;E&amp;gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;&amp;nbsp;public&lt;/span&gt; Iterable &amp;lt;Position &amp;lt;E&amp;gt;&amp;gt; positions();&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times; font-size: small;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;div style=&quot;display: inline !important;&quot;&gt;&lt;div style=&quot;display: inline !important; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;display: inline !important;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;display: inline !important; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size();&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position &amp;lt;E&amp;gt; first() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyListException;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position &amp;lt;E&amp;gt; last() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyListException;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position &amp;lt;E&amp;gt; prev(Position &amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException,&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;BoundaryViolationException;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position &amp;lt;E&amp;gt; next(Position &amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException,&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;BoundaryViolationException;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; addBefore(Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; addAfter(Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; void addFirst(E e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; void addLast(E e);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E remove(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E set (Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; NodePositionList&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; PositionList&amp;lt;E&amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;static&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;listsCounter&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; = 0;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;protected&lt;/span&gt; DNode&amp;lt;E&amp;gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;, &lt;span style=&quot;color: #0000d0;&quot;&gt;trailer&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; NodePositionList()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;listsCounter&lt;span style=&quot;color: black;&quot;&gt;++;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; DNode&amp;lt;E&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;trailer&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; DNode&amp;lt;E&amp;gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;,&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;,&lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;header&lt;span style=&quot;color: black;&quot;&gt;.setIdLista(&lt;/span&gt;listsCounter&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;trailer&lt;span style=&quot;color: black;&quot;&gt;.setIdLista(&lt;/span&gt;listsCounter&lt;span style=&quot;color: black;&quot;&gt;);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size() {&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty() {&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; == 0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; first() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyListException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyListException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getNext();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; last() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyListException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyListException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;trailer&lt;/span&gt;.getPrev();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; prev(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException,&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (tmp.getPrev() == &lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; BoundaryViolationException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp.getPrev();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; next(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException,&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;BoundaryViolationException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (tmp.getNext() == &lt;span style=&quot;color: #0000d0;&quot;&gt;trailer&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; BoundaryViolationException();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp.getNext();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; addBefore(Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; nuovoNodo = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; DNode&amp;lt;E&amp;gt;(e,tmp.getPrev(),tmp,&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getIdLista());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;tmp.getPrev().setNext(nuovoNodo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;tmp.setPrev(nuovoNodo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; nuovoNodo;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Position&amp;lt;E&amp;gt; addAfter(Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; nuovoNodo = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; DNode&amp;lt;E&amp;gt;(e,tmp,tmp.getNext(),&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getIdLista());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;tmp.getNext().setPrev(nuovoNodo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;tmp.setNext(nuovoNodo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; nuovoNodo;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; addFirst(E e)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;DNode&amp;lt;E&amp;gt; nuovoNodo = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; DNode&amp;lt;E&amp;gt;(e,&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;,&lt;span style=&quot;color: #0000d0;&quot;&gt;trailer&lt;/span&gt;,&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getIdLista());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.setNext(nuovoNodo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;trailer&lt;/span&gt;.setPrev(nuovoNodo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;DNode&amp;lt;E&amp;gt; tmp = &lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getNext();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;DNode&amp;lt;E&amp;gt; nuovoNodo = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; DNode&amp;lt;E&amp;gt;(e,&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;,tmp,&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getIdLista());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;tmp.setPrev(nuovoNodo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.setNext(nuovoNodo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; addLast(E e)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; tmp = &lt;span style=&quot;color: #0000d0;&quot;&gt;trailer&lt;/span&gt;.getPrev();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; nuovoNodo = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; DNode&amp;lt;E&amp;gt;(e,tmp,&lt;span style=&quot;color: #0000d0;&quot;&gt;trailer&lt;/span&gt;,&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getIdLista());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;tmp.setNext(nuovoNodo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;trailer&lt;/span&gt;.setPrev(nuovoNodo);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E remove(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; tmp = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;tmp.getPrev().setNext(tmp.getNext());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;tmp.getNext().setPrev(tmp.getPrev());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;--;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp.element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E set(Position&amp;lt;E&amp;gt; p, E e) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; tmpnode = checkPosition(p);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E tmpEl = tmpnode.element();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;tmpnode.setElement(e);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmpEl;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; DNode&amp;lt;E&amp;gt; checkPosition(Position&amp;lt;E&amp;gt; p) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; InvalidPositionException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (p == &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;) &lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;null position&quot;&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (p == &lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;) &lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;header&quot;&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (p == &lt;span style=&quot;color: #0000d0;&quot;&gt;trailer&lt;/span&gt;) &lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;trailer&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;try&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;DNode&amp;lt;E&amp;gt; temp = (DNode&amp;lt;E&amp;gt;) p;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;// casting&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; ((temp.getPrev() == &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;) || (temp.getNext() == &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;not in a NodeList&quot;&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (temp.getIdLista() != &lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getIdLista() || temp.getIdLista()==0)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Given position does not belong to NodeList &quot;&lt;/span&gt;+&lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getIdLista());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; temp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;catch&lt;/span&gt; (ClassCastException e)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; InvalidPositionException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;not a DNode&quot;&lt;/span&gt;);&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String stringa = &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;NodePositionlist id:&quot;&lt;/span&gt;+ &lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getIdLista() +&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; [ &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; aNode = &lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getNext();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;stringa += aNode.element() + &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;aNode = aNode.getNext();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringa += &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;] size:&quot;&lt;/span&gt;+&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; stringa;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; PositionList&amp;lt;E&amp;gt; creaCopia()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NodePositionList&amp;lt;E&amp;gt; copia = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;E&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; oldNode = &lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getNext();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;size(); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;copia.addLast(oldNode.element());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;oldNode = oldNode.getNext();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; copia;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterator&amp;lt;E&amp;gt; iterator()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #319472;&quot;&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;E[] &lt;span style=&quot;text-decoration: underline;&quot;&gt;tmp&lt;/span&gt; = (E[]) new Object[size];&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; aNode = header.getNext();&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(&lt;span style=&quot;text-decoration: underline;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;size; i++)&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;tmp&lt;/span&gt;[i] = aNode.element();&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;aNode = aNode.getNext();&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return new LinkedIterator&amp;lt;E&amp;gt;(&lt;span style=&quot;text-decoration: underline;&quot;&gt;tmp&lt;/span&gt;);*/&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ElementIterator&amp;lt;E&amp;gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;this&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; Iterable&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; positions()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt; tmp =&amp;nbsp; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; NodePositionList&amp;lt;Position&amp;lt;E&amp;gt;&amp;gt;();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DNode&amp;lt;E&amp;gt; aNode = &lt;span style=&quot;color: #0000d0;&quot;&gt;header&lt;/span&gt;.getNext();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;tmp.addLast(aNode);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;aNode = aNode.getNext();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;tmp.addLast(aNode);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; tmp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times; font-size: small;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;div style=&quot;display: inline !important;&quot;&gt;&lt;div style=&quot;display: inline !important;&quot;&gt;&lt;div style=&quot;display: inline !important; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 19px;&quot;&gt;&lt;div style=&quot;display: inline !important;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Times; font-size: small; white-space: normal;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;b&gt;&lt;div style=&quot;display: inline !important;&quot;&gt;&lt;div style=&quot;display: inline !important;&quot;&gt;&lt;div style=&quot;display: inline !important; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;display: inline !important; font: normal normal normal 14px/normal Monaco; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/b&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/*&lt;span style=&quot;text-decoration: underline;&quot;&gt;Scrivere&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;funzione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ricorsiva&lt;/span&gt; void reverse(PositionList&amp;lt;E&amp;gt; L)&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;che&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;inverte&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;lista&lt;/span&gt; L.&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Definizione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ricorsiva&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;lista&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;inversa&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;di&lt;/span&gt; L=&amp;lt;e1,e2,...,&lt;span style=&quot;text-decoration: underline;&quot;&gt;en&lt;/span&gt; &amp;gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;inversa&lt;/span&gt;(L)=L &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; n≤1&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Inversa&lt;/span&gt;(L)= &lt;span style=&quot;text-decoration: underline;&quot;&gt;&amp;lt;en&amp;gt;&lt;/span&gt;+ &lt;span style=&quot;text-decoration: underline;&quot;&gt;inversa&lt;/span&gt;(&amp;lt;e1,...,&lt;span style=&quot;text-decoration: underline;&quot;&gt;en&lt;/span&gt;-1 &amp;gt;) &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; n&amp;gt;1&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;*/&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;//&lt;span style=&quot;text-decoration: underline;&quot;&gt;funzione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ricorsiva&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;versione&lt;/span&gt; 2&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; reverse(PositionList&amp;lt;E&amp;gt; L)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NodePositionList&amp;lt;E&amp;gt; lista = (NodePositionList&amp;lt;E&amp;gt;) L;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (lista.size() &amp;gt; 1)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;E tmp = lista.remove(lista.last());&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;lista.reverse(lista);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;lista.addFirst(tmp);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/*&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; //&lt;span style=&quot;text-decoration: underline;&quot;&gt;funzione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;ricorsiva&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;versione&lt;/span&gt; 1&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public PositionList&amp;lt;E&amp;gt; reverse(PositionList&amp;lt;E&amp;gt; L)&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;NodePositionList&amp;lt;E&amp;gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;lista&lt;/span&gt; = (NodePositionList&amp;lt;E&amp;gt;) L;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (lista.size() &amp;lt;= 1)&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return &lt;span style=&quot;text-decoration: underline;&quot;&gt;lista&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;E &lt;span style=&quot;text-decoration: underline;&quot;&gt;tmp&lt;/span&gt; = lista.remove(lista.last());&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;lista.reverse(&lt;span style=&quot;text-decoration: underline;&quot;&gt;lista&lt;/span&gt;).addFirst(&lt;span style=&quot;text-decoration: underline;&quot;&gt;tmp&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;return &lt;span style=&quot;text-decoration: underline;&quot;&gt;lista&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;*/&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/*&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; //&lt;span style=&quot;text-decoration: underline;&quot;&gt;funzione&lt;/span&gt; non &lt;span style=&quot;text-decoration: underline;&quot;&gt;ricorsiva&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void reverse(PositionList&amp;lt;E&amp;gt; L)&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayStack&amp;lt;E&amp;gt; stack = new ArrayStack&amp;lt;E&amp;gt;();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;while(!L.isEmpty())&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;stack.push(L.remove(L.first()));&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;while(!stack.isEmpty())&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;L.addLast(stack.pop());&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;*/&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;/span&gt; &lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/03/strutture-dati-arraylist-e-nodelist.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-1421312580408385578</guid><pubDate>Wed, 16 Mar 2011 14:41:00 +0000</pubDate><atom:updated>2011-03-18T11:46:40.900+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">esercizi</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">Stack</category><category domain="http://www.blogger.com/atom/ns#">Strutture Dati</category><title>Esercizi Strutture Dati - Stack</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjV09saxhocG7usuxpiKSFz5vBMmhJVf1X32VSPUM-yWwrpBFxH0-Uqblw9pqNFUYaVR8_qYRlHfX3oETQ06W3CNi-sSBPd73Cwi0yAje-zjR5ljwptwoduCJrzXyqkHUpu1xHwvuEskFb/s1600/300px-Data_stack.svg.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;144&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjV09saxhocG7usuxpiKSFz5vBMmhJVf1X32VSPUM-yWwrpBFxH0-Uqblw9pqNFUYaVR8_qYRlHfX3oETQ06W3CNi-sSBPd73Cwi0yAje-zjR5ljwptwoduCJrzXyqkHUpu1xHwvuEskFb/s200/300px-Data_stack.svg.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;!-- &lt;edindex&gt; --&gt;&lt;br /&gt;
Questo è il primo di una serie di posts utili agli studenti dell&#39;&lt;a href=&quot;http://www.unisa.it/&quot;&gt;Università degli studi di Salerno&lt;/a&gt; che studiano Informatica o Informatica Applicata e devono sostenere l&#39;esame di &lt;a href=&quot;http://www.dia.unisa.it/professori/latorre/didattica/SD/&quot;&gt;Strutture Dati&lt;/a&gt;&amp;nbsp;(SD) o di Laboratorio di Algoritmi e Strutture Dati (LASD) con il professor &lt;a href=&quot;http://www.dia.unisa.it/professori/latorre/&quot;&gt;Salvatore La Torre&lt;/a&gt;.&lt;br /&gt;
Nel seguito di questo articolo, e in quelli successivi, ci saranno i miei esercizi svolti durante il corso; esercizi che rappresentano un requisito essenziale per superare l&#39;esame. Ho deciso di postare il mio lavoro per mantenerne una copia online, e in modo che chiunque possa consultarlo a piacimento; Invito i miei colleghi studenti a desistere dalla tentazione di presentarvi all&#39;esame con i miei esercizi, (che per quanto io possa essere sicuro che siano corretti potrebbero comunque contenere errori) ma al massimo di usarli per confrontarli con i vostri.&lt;br /&gt;
&lt;!-- &lt;/EdIndex&gt; --&gt;&lt;br /&gt;
&lt;hr /&gt;&lt;span class=&quot;fullpost&quot;&gt;Di seguito elenco gli esercizi sulla prima parte del corso, aggiornati al 16/03/2011 &lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;h4&gt;Le Eccezioni&lt;/h4&gt;&lt;div&gt;Le eccezioni sono tutte uguali quindi ne scrivo una soltanto:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; EmptyStackException &lt;span style=&quot;color: #a10068;&quot;&gt;extends&lt;/span&gt; RuntimeException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;static&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;final&lt;span style=&quot;color: black;&quot;&gt; String &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;DEFAULTMSG&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Stack Vuoto!&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; EmptyStackException()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;DEFAULTMSG&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; EmptyStackException(String err)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;super&lt;/span&gt;(err);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;h3&gt;Esercizi sullo Stack&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;public&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;interface&lt;span style=&quot;color: black;&quot;&gt; Stack &amp;lt;E&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Controlla&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;lo&lt;/span&gt; stack è &lt;span style=&quot;text-decoration: underline;&quot;&gt;vuoto&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; true &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;lo&lt;/span&gt; stack è &lt;span style=&quot;text-decoration: underline;&quot;&gt;vuoto&lt;/span&gt;, false &lt;span style=&quot;text-decoration: underline;&quot;&gt;altrimenti&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Ottiene&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;il&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;valore&lt;/span&gt; in &lt;span style=&quot;text-decoration: underline;&quot;&gt;cima&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;allo&lt;/span&gt; stack.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; l&#39;elemento &lt;span style=&quot;text-decoration: underline;&quot;&gt;al&lt;/span&gt; top &lt;span style=&quot;text-decoration: underline;&quot;&gt;dello&lt;/span&gt; stack&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; EmptyStackException &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;invocato&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;su&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;uno&lt;/span&gt; stack &lt;span style=&quot;text-decoration: underline;&quot;&gt;vuoto&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E top() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyStackException;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Elimina&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elemento&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;dalla&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;cima&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;dello&lt;/span&gt; stack.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; l&#39;elemento &lt;span style=&quot;text-decoration: underline;&quot;&gt;cancellato&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@throws&lt;/span&gt; EmptyStackException &lt;span style=&quot;text-decoration: underline;&quot;&gt;se&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;invocato&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;su&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;uno&lt;/span&gt; stack &lt;span style=&quot;text-decoration: underline;&quot;&gt;vuoto&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E pop() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyStackException;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Inserisce&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;elemento&lt;/span&gt; in &lt;span style=&quot;text-decoration: underline;&quot;&gt;cima&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;allo&lt;/span&gt; stack.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@param&lt;/span&gt; e l&#39;elemento &lt;span style=&quot;text-decoration: underline;&quot;&gt;da&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;inserire&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; push(E o) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; FullStackException;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;Da&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;la&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;dimensione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;dello&lt;/span&gt; stack.&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;color: #89afcc;&quot;&gt;@return&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;un&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;da&lt;/span&gt; 0 &lt;span style=&quot;text-decoration: underline;&quot;&gt;alla&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;dimensione&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;massima&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;dello&lt;/span&gt; stack&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: 14.5px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #cc9a02; font: normal normal normal 9.4px/normal Wingdings;&quot;&gt;􏰀 &lt;/span&gt;Completare l’implementazione della classe generica &lt;span style=&quot;color: #006533;&quot;&gt;ArrayStack&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.5px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #006533;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; ArrayStack&amp;lt;E&amp;gt; &lt;span style=&quot;color: #a10068;&quot;&gt;implements&lt;/span&gt; Stack&amp;lt;E&amp;gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;private&lt;/span&gt; E &lt;span style=&quot;color: #0000d0;&quot;&gt;stack&lt;/span&gt;[];&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;private&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;public&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;static&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;final&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;int&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;CAPACITY&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; = 1024;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; ArrayStack()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;CAPACITY&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;color: #777777; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; ArrayStack(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; cap)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt; = cap;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;stack&lt;/span&gt; = (E[])&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; Object[&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; = 0;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt; == 0);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E top() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyStackException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyStackException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Stack Vuoto!&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000d0;&quot;&gt;stack&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; E pop() &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; EmptyStackException&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; EmptyStackException(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;Stack Vuoto!&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;E o = &lt;span style=&quot;color: #0000d0;&quot;&gt;stack&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;stack&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;-1] = &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;--;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; o;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; push(E o) &lt;span style=&quot;color: #a10068;&quot;&gt;throws&lt;/span&gt; FullStackException&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;size&lt;span style=&quot;color: black;&quot;&gt; == &lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #319472; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;//throw new FullStackException(&quot;Stack &lt;span style=&quot;text-decoration: underline;&quot;&gt;Pieno&lt;/span&gt;!&quot;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #0000d0; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt; = &lt;/span&gt;capacity&lt;span style=&quot;color: black;&quot;&gt;*2;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;E nuovoStack[] = (E[])&lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; Object[&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;nuovoStack[i]=&lt;span style=&quot;color: #0000d0;&quot;&gt;stack&lt;/span&gt;[i];&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;stack&lt;/span&gt; = &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;stack&lt;/span&gt; = nuovoStack;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;nuovoStack = &lt;span style=&quot;color: #a10068;&quot;&gt;null&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;stack&lt;/span&gt;[&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;] = o;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; size() {&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;return&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; String toString()&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String response = &lt;/span&gt;&quot;ArrayStack Elements:[ &quot;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i = 0; i&amp;lt;&lt;span style=&quot;color: #0000d0;&quot;&gt;size&lt;/span&gt;; i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;response += (&lt;span style=&quot;color: #0000d0;&quot;&gt;stack&lt;/span&gt;[i]+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; &quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;response+= &lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;] size:&quot;&lt;/span&gt;+size()+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot; capacity: &quot;&lt;/span&gt;+&lt;span style=&quot;color: #0000d0;&quot;&gt;capacity&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;return&lt;/span&gt; response;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font: 14.5px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;Scrivere un metodo Java che usa uno stack per calcolare il reverse di una stringa&lt;/div&gt;&lt;div style=&quot;font: 12.6px Times; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #3b822e; font: normal normal normal 7.5px/normal Wingdings;&quot;&gt;􏰁 &lt;/span&gt;Es. Il reverse di “laboratorio” è “oirotarobal”&lt;/div&gt;&lt;div style=&quot;font: 12.6px Times; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;import&lt;/span&gt; java.util.*;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; StringReverse&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;/**&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &lt;span style=&quot;text-decoration: underline;&quot;&gt;uso&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;uno&lt;/span&gt; stack per &lt;span style=&quot;text-decoration: underline;&quot;&gt;invertire&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;una&lt;/span&gt; &lt;span style=&quot;text-decoration: underline;&quot;&gt;stringa&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #4370ce; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; main(String[] args)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayStack&amp;lt;String&amp;gt; s = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayStack&amp;lt;String&amp;gt;(5);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Scanner in = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; Scanner(System.&lt;span style=&quot;color: #0000d0;&quot;&gt;in&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.print(&lt;/span&gt;&quot;Inserisci una riga: &quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String riga = in.nextLine();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String rigaInvertita =&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;&quot;&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt; riga.length(); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;s.push(riga.charAt(i)+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;while&lt;/span&gt;(!s.isEmpty())&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;rigaInvertita += s.pop();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;La riga invertita è: &quot;&lt;/span&gt;+rigaInvertita);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font: 12.0px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;Scrivere un metodo che riceve in input una stringa contenente parentesi tonde e restituisce &lt;span style=&quot;color: #2c61f6;&quot;&gt;true &lt;/span&gt;se le parentesi sono ben accoppiate e &lt;span style=&quot;color: #2c61f6;&quot;&gt;false &lt;/span&gt;altrimenti.&lt;/div&gt;&lt;div style=&quot;font: 10.6px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #3b822e; font: normal normal normal 6.9px/normal Wingdings;&quot;&gt;􏰁 &lt;/span&gt;&lt;span style=&quot;font: normal normal normal 11.6px/normal Helvetica;&quot;&gt;Esempio: &lt;/span&gt;&lt;span style=&quot;color: #cc9a02; font: normal normal normal 6.9px/normal Wingdings;&quot;&gt;􏰀 &lt;/span&gt;x((abc)()) è un’espressione ben parentesizzata &lt;span style=&quot;color: #cc9a02; font: normal normal normal 6.9px/normal Wingdings;&quot;&gt;􏰀􏰀&lt;/span&gt;(as(df)))( nonèun’espressionebenparentesizzata&lt;/div&gt;&lt;div style=&quot;font: 12.0px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #cc9a02; font: normal normal normal 7.8px/normal Wingdings;&quot;&gt;􏰀 &lt;/span&gt;Modificare la funzione in modo che funzioni con stringhe contenenti sia parentesi tonde che parentesi quadre&lt;/div&gt;&lt;div style=&quot;font: 10.6px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #3b822e; font: normal normal normal 6.9px/normal Wingdings;&quot;&gt;􏰁 &lt;/span&gt;&lt;span style=&quot;font: normal normal normal 11.6px/normal Helvetica;&quot;&gt;Esempio: &lt;/span&gt;&lt;span style=&quot;color: #cc9a02; font: normal normal normal 6.9px/normal Wingdings;&quot;&gt;􏰀 &lt;/span&gt;x[(abc)()]([]) è un’espressione ben parentesizzata &lt;span style=&quot;color: #cc9a02; font: normal normal normal 6.9px/normal Wingdings;&quot;&gt;􏰀 &lt;/span&gt;(as(df)]( non è un’espressione ben parentesizzata&lt;/div&gt;&lt;div style=&quot;font: 10.6px Helvetica; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;import&lt;/span&gt; java.util.*;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;class&lt;/span&gt; ControlloParentesiTonde&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #a10068;&quot;&gt;void&lt;/span&gt; main(String[] args)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayStack&amp;lt;String&amp;gt; s = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; ArrayStack&amp;lt;String&amp;gt;(5);&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Scanner in = &lt;span style=&quot;color: #a10068;&quot;&gt;new&lt;/span&gt; Scanner(System.&lt;span style=&quot;color: #0000d0;&quot;&gt;in&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.println(&lt;/span&gt;&quot;Verifica Annidamento Parentesi Tonde, Quadre e Graffe\n&quot;&lt;span style=&quot;color: black;&quot;&gt; +&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt; &amp;nbsp; &lt;/span&gt;&quot;-----------------------------------------------------&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.print(&lt;/span&gt;&quot;Scrivi l&#39;espressione: &quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String riga = in.nextLine();&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;boolean&lt;/span&gt; correct = &lt;span style=&quot;color: #a10068;&quot;&gt;true&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #a10068;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt; riga.length(); i++)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;try&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (riga.charAt(i)==&lt;span style=&quot;color: #3900ff;&quot;&gt;&#39;(&#39;&lt;/span&gt; || riga.charAt(i)==&lt;span style=&quot;color: #3900ff;&quot;&gt;&#39;[&#39;&lt;/span&gt; || riga.charAt(i)==&lt;span style=&quot;color: #3900ff;&quot;&gt;&#39;{&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;s.push(riga.charAt(i)+&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;&quot;&lt;/span&gt;);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (riga.charAt(i)==&lt;span style=&quot;color: #3900ff;&quot;&gt;&#39;)&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (s.top().equals(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;(&quot;&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;s.pop();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (riga.charAt(i)==&lt;span style=&quot;color: #3900ff;&quot;&gt;&#39;]&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (s.top().equals(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;[&quot;&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;s.pop();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (riga.charAt(i)==&lt;span style=&quot;color: #3900ff;&quot;&gt;&#39;}&#39;&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (s.top().equals(&lt;span style=&quot;color: #3900ff;&quot;&gt;&quot;{&quot;&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;s.pop();&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;catch&lt;/span&gt;(EmptyStackException e)&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;correct = &lt;span style=&quot;color: #a10068;&quot;&gt;false&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px; min-height: 19.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #a10068;&quot;&gt;if&lt;/span&gt; (correct &amp;amp;&amp;amp; s.isEmpty())&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.println(&lt;/span&gt;&quot;Allineamento parentesi corretto&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #a10068; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;else&lt;/div&gt;&lt;div style=&quot;color: #3900ff; font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.&lt;/span&gt;&lt;span style=&quot;color: #0000d0;&quot;&gt;out&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.println(&lt;/span&gt;&quot;Allineamento parentesi ERRATO&quot;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;font: 14.0px Monaco; margin: 0.0px 0.0px 0.0px 0.0px;&quot;&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;http://emdief.blogspot.com/2011/03/esercizi-strutture-dati-queue-e-deque.html&quot;&gt;Parte 2: Esercizi di Strutture Dati su Code e Deque&lt;/a&gt;&lt;br /&gt;
&lt;/span&gt; &lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/03/esercizi-strutture-dati-stack.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjV09saxhocG7usuxpiKSFz5vBMmhJVf1X32VSPUM-yWwrpBFxH0-Uqblw9pqNFUYaVR8_qYRlHfX3oETQ06W3CNi-sSBPd73Cwi0yAje-zjR5ljwptwoduCJrzXyqkHUpu1xHwvuEskFb/s72-c/300px-Data_stack.svg.png" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-3753292881940968199</guid><pubDate>Mon, 19 Jul 2010 10:47:00 +0000</pubDate><atom:updated>2010-07-19T12:51:16.207+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">rimedi morso di medusa</category><category domain="http://www.blogger.com/atom/ns#">sos meduse</category><category domain="http://www.blogger.com/atom/ns#">tipi di meduse</category><title>Le Meduse del Mediterraneo</title><description>&lt;!--&lt;edindex&gt;--&gt;&lt;h4&gt;Ecco le immagini e le caratteristiche peculiari di ogni specie di medusa presente nel nostro mar Mediterraneo.&lt;/h4&gt;Purtroppo negli ultimi 10 anni il mar Mediterraneo ha subito un progressivo riscaldamento tuttora in corso. Questo aumento della temperatura ha reso le nostre acque molto simili a quelle Tropicali, rendendole sempre più adatte ad ospitare nuove specie che prima non riuscivano a viverci. Vediamo quindi di anno in anno un prolificarsi sempre maggiore di specie nuove per i nostri mari, tra cui anche le &quot;antipatiche&quot; meduse, che nonostante vivano bene anche in acque fredde, non disprezzano assolutamente le acque calde, che amplificano le condizioni ideali per la prolificazione e favoriranno anche l&#39;inserimento di specie che preferiscono temperature più alte. Quindi per il futuro ci si aspetta di veder crescere sempre più il numero e la diversità biologica di queste bombe gelatinose urticanti. Questo è il motivo per cui ho deciso di fare un piccolo riassunto con caratteristiche e foto di ogni specie che potremmo incontrare durante le nostre vacanze estive.  &lt;br /&gt;
&lt;hr /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;div&gt;&lt;h4&gt;&lt;a href=&quot;http://it.wikipedia.org/wiki/Pelagia_noctiluca&quot;&gt;La Pelagia&lt;/a&gt;&lt;/h4&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_1GdbPGLAK9qeMsY0MBENRgbS0UoQ6IpiL-s0g7btAkrSLcWzTr82PN38yRSViUxGbtVRvRhdjE-NwlWttwMr1Sq7WdUFDxTOjjnJlGU9JjV6XtYfNyNrXXFSfqBjYQS_mmJdQuxA9sLV/s1600/pelagia.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_1GdbPGLAK9qeMsY0MBENRgbS0UoQ6IpiL-s0g7btAkrSLcWzTr82PN38yRSViUxGbtVRvRhdjE-NwlWttwMr1Sq7WdUFDxTOjjnJlGU9JjV6XtYfNyNrXXFSfqBjYQS_mmJdQuxA9sLV/s200/pelagia.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Questa è una delle tipologie più comuni di medusa da sempre presente nel Mediterraneo, ha un ombrello di colore marrone-rosato o rosa-violetto di circa 10 cm. di diametro, traslucido, composto da 16 lobi da cui partono &lt;b&gt;8 tentacoli retrattili semi-trasparenti e urticanti&lt;/b&gt;, che partono dai bordi e possono arrivare a lunghezze &lt;b&gt;anche di 10 metri&lt;/b&gt;. I &lt;b&gt;tentacoli orali&lt;/b&gt;, dello stesso colore dell&#39;ombrello, sono lunghi invece &lt;b&gt;30 cm&lt;/b&gt;. Si nutre di plancton e piccoli pesci che cattura con i tentacoli urticanti.&lt;/div&gt;&lt;hr /&gt;&lt;div&gt;&lt;h4&gt;&lt;a href=&quot;http://it.wikipedia.org/wiki/Aurelia_aurita&quot;&gt;La Aurelia&lt;/a&gt;&lt;/h4&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgngVZ9bzT9ug2C3QB9yGDqO6Xs1mkUHdNBYMJciJU9RRAQdf86tjrtjwR_jo0DGpvAvAUyPqhRg9T9r8UdItBAMC-1OF3CtTzmHTSp94LjcfxRVhmllRRjEf_e0pN-QoM4Y077CAYvadx-/s1600/aurelia.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgngVZ9bzT9ug2C3QB9yGDqO6Xs1mkUHdNBYMJciJU9RRAQdf86tjrtjwR_jo0DGpvAvAUyPqhRg9T9r8UdItBAMC-1OF3CtTzmHTSp94LjcfxRVhmllRRjEf_e0pN-QoM4Y077CAYvadx-/s200/aurelia.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Questo tipo di medusa è diffusa notevolmente in tutto il pianeta, anche se non massicciamente nel Mediterraneo, e nonostante sia considerata innocua possiede dei &lt;b&gt;sottili e corti tentacoli urticanti&lt;/b&gt; che scendono dal bordo dell&#39;ombrello e negli esemplari adulti si possono notare anche 4 tentacoli più spessi che partono dal centro dell&#39;ombrello. Viene facilmente riconosciuta dal suo ombrello di forma sferica color bianco/trasparente, e dalle caratteristiche 4 gonadi tonde sulla sua sommità, che sembrano disegnare la forma di un quadrifoglio. Probabilmente è considerata poco pericolosa proprio per la scarsa lunghezza dei suoi tentacoli che consentono di limitare i rischi semplicemente standone alla larga.&lt;/div&gt;&lt;hr /&gt;&lt;div&gt;&lt;h4&gt;&lt;a href=&quot;http://it.wikipedia.org/wiki/Physalia_physalis&quot;&gt;La Physalia Physalis&lt;/a&gt;&lt;/h4&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPmIb5TGX3vn4eHYmBmftjQsKQG4DPJHCsLuJTBwyJu9v0jjTPtWSLmqvlsaiR1gKaTbkfynZBrVfEQIPVpRhuucr21Oe6u90Opl0eQVT4D28_xjRXo5k9mGzmgph-0_2DQgnLoVuuFxNk/s1600/250px-Portuguese_Man-O-War_(Physalia_physalis).jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPmIb5TGX3vn4eHYmBmftjQsKQG4DPJHCsLuJTBwyJu9v0jjTPtWSLmqvlsaiR1gKaTbkfynZBrVfEQIPVpRhuucr21Oe6u90Opl0eQVT4D28_xjRXo5k9mGzmgph-0_2DQgnLoVuuFxNk/s200/250px-Portuguese_Man-O-War_(Physalia_physalis).jpg&quot; width=&quot;145&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Questa è quella che vi auguro di non incontrare, La Physalia Physalis detta Caravella Portoghese, è spesso confusa per una medusa, ma in realtà si tratta di una colonia di 4 tipi diversi di polipi, che dipendono l&#39;un l&#39;altro per la sopravvivenza. La Physalia Physalis è composta da una sacca galleggiante di circa 15 cm. a cui sono attaccati dei&lt;b&gt; tentacoli lunghi fino a 30 metri fortemente urticanti&lt;/b&gt;. La parte emersa è di colore azzurro violacea e a volte tende al fucsia. Galleggia sospinta dal vento ad un&#39;angolazione che dipende dalla parte emersa e dalla resistenza della parte sommersa. Ha &lt;b&gt;più di 10 tipi di veleni diversi sui suoi tentacoli&lt;/b&gt;, ognuno caratterizzato da un suo proprio colore, non sono conosciuti ancora rimedi per alcuni tipi dei suoi veleni. I tentacoli di questo pericoloso animale &lt;b&gt;possono provocare la paralisi e persino la morte per arresto cardiaco&lt;/b&gt;, e una semplice puntura può essere molto dolorosa.&lt;/div&gt;&lt;hr /&gt;&lt;div&gt;&lt;h4&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Mnemiopsis_leidyi&quot;&gt;La Mnemiopsis leidyi&lt;/a&gt;&lt;/h4&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlibK4hTnfVAoLdQle93LghIv4GbgWz9eau5TcMnU2Fq_xUM1lXwiYfipE9pu_tqkL-g9GoWi1JzW7mL6oxWwrKaOgmcetaEG5nHSDdNW3Z9B1sp8pDz47J6vmlBdcRKggEBgdkUQGPyrQ/s1600/cte003.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;133&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlibK4hTnfVAoLdQle93LghIv4GbgWz9eau5TcMnU2Fq_xUM1lXwiYfipE9pu_tqkL-g9GoWi1JzW7mL6oxWwrKaOgmcetaEG5nHSDdNW3Z9B1sp8pDz47J6vmlBdcRKggEBgdkUQGPyrQ/s200/cte003.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Finalmente vi presento una medusa che &lt;b&gt;non è pericolosa&lt;/b&gt; per l&#39;uomo in quanto &lt;b&gt;non punge&lt;/b&gt;. Il suo corpo è composto al 97% di acqua, ha forma ovale, colore trasparente, e lungo il corpo, verticalmente ha quattro file di pettini cigliati che emettono colori luminescenti blu-verdi se disturbati. Possono raggiungere dai 7 ai 12 cm. di lunghezza e 2,5 cm. di diametro. Si nutrono principalmente di plankton e uova o larve di pesci.&lt;/div&gt;&lt;hr&gt;&lt;div&gt;&lt;h4&gt;Cosa fare se venite punti da una medusa?&lt;/h4&gt;Ecco una serie di rimedi al fastidioso bruciore:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;I più previdenti potranno uscire dall&#39;acqua e spalmare immediatamente sulla zona urticata una pomata a base di ammoniaca, funzionano egregiamente anche le pomate after-bite per punture di insetti;&lt;br /&gt;
&lt;li&gt;Strofinare la zona urticata con della sabbia bollente;&lt;br /&gt;
&lt;li&gt;In casi estremi in cui siete sprovvisti di una pomata e non c&#39;è sabbia intorno a voi, potrete ricorrere al più vecchio rimedio che è l&#39;urina. &lt;br /&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;/span&gt;&lt;!--&lt;/EdIndex&gt;--&gt;  &lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/07/le-meduse-del-mediterraneo.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_1GdbPGLAK9qeMsY0MBENRgbS0UoQ6IpiL-s0g7btAkrSLcWzTr82PN38yRSViUxGbtVRvRhdjE-NwlWttwMr1Sq7WdUFDxTOjjnJlGU9JjV6XtYfNyNrXXFSfqBjYQS_mmJdQuxA9sLV/s72-c/pelagia.jpg" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-6629538739012354909</guid><pubDate>Sun, 18 Jul 2010 22:57:00 +0000</pubDate><atom:updated>2010-07-19T12:52:13.187+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">freeware</category><category domain="http://www.blogger.com/atom/ns#">riconoscitore canzoni</category><category domain="http://www.blogger.com/atom/ns#">shazam</category><category domain="http://www.blogger.com/atom/ns#">tunatic</category><title>Tunatic, lo Shazam gratuito per Mac e Pc</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJzIJC5yTeNV_Z0RmoFNvXfzmC6CpgOOUCN7zI4WmfCLAowOdXdvjvdbLd2l13cmKS1DcsaeviAgjm6ebEEgC1RhTzd4Ct6k63rIUvQFpAH8uKGkj9t7BK3B2v4z0OkFdSMLSUb2N36JvU/s1600/Tunatic.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJzIJC5yTeNV_Z0RmoFNvXfzmC6CpgOOUCN7zI4WmfCLAowOdXdvjvdbLd2l13cmKS1DcsaeviAgjm6ebEEgC1RhTzd4Ct6k63rIUvQFpAH8uKGkj9t7BK3B2v4z0OkFdSMLSUb2N36JvU/s320/Tunatic.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;!--&lt;edindex&gt;--&gt;&lt;br /&gt;
&lt;br /&gt;
Finalmente ho trovato una versione del famoso software Shazam gratuita per Windows e Mac. Per chi non avesse mai sentito parlare di questo programma, è un utilissimo software spuntato originariamente su iPhone che permette di reperire il Titolo e l&#39;Autore di una canzone da un database online, semplicemente ascoltandola. &lt;br /&gt;
&lt;!--&lt;/EdIndex&gt;--&gt; &lt;br /&gt;
&lt;hr /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-841cY9pkqPqGxralMnMaIOSui7fVhunbJIK-VSjvX7F4vP20aXfyQyCJAWgaRjbPBbBOfoidzR_BiM47XlG80ULvNAu5Winp54lkKfw53E2xKElWvJN0eDDS37KQYa0MbbWZoKlVmPd6/s1600/tunaticReady.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-841cY9pkqPqGxralMnMaIOSui7fVhunbJIK-VSjvX7F4vP20aXfyQyCJAWgaRjbPBbBOfoidzR_BiM47XlG80ULvNAu5Winp54lkKfw53E2xKElWvJN0eDDS37KQYa0MbbWZoKlVmPd6/s320/tunaticReady.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;!--&lt;EdIndex&gt;--&gt; &lt;br /&gt;
Hai Mai pensato, &quot;Che canzone è questa?&quot; Lasciala ascoltare a Tunatic e avrai in pochi secondi il titolo e il nome dell&#39;artista. Tunatic è come un motore di ricerca basato su suoni. Tutto ciò di cui avrai bisogno per farlo funzionare è un microfono e un accesso ad internet. Il suo funzionameno è semplicissimo, cliccando sul pulsante di ricerca di Tunatic, il programma si collegherà ad un server, al quale invierà le caratteristiche della canzone ascoltata, il server cercherà nel suo database, restituendo le informazioni della canzone. Niente di più semplice in un programmino che pesa meno di 1Mb.&lt;br /&gt;
&lt;!--&lt;/EdIndex&gt;--&gt; &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkZNTSHX5x4YUi4L4SVfGvqFeVlp2W_SlUNPaCFRiAWxFiGRXG1V6hCj_cmglxOgVjfGFtt_BjDCv8DNTs2PGPGofP8-jImRSw_9QfccYdp1TsTK8rXWg4GzBiI7rEzs3l6ccm8YbMrVeh/s1600/tunaticOK.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkZNTSHX5x4YUi4L4SVfGvqFeVlp2W_SlUNPaCFRiAWxFiGRXG1V6hCj_cmglxOgVjfGFtt_BjDCv8DNTs2PGPGofP8-jImRSw_9QfccYdp1TsTK8rXWg4GzBiI7rEzs3l6ccm8YbMrVeh/s320/tunaticOK.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://wildbits.com/files/TunaticSetup.exe&quot;&gt;Scarica Tunatic per Windows&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://wildbits.com/files/Tunatic101b.dmg&quot;&gt;Tunatic 1.0.1b per Mac&lt;/a&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/07/tunatic-lo-shazam-gratuito-per-mac-e-pc.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJzIJC5yTeNV_Z0RmoFNvXfzmC6CpgOOUCN7zI4WmfCLAowOdXdvjvdbLd2l13cmKS1DcsaeviAgjm6ebEEgC1RhTzd4Ct6k63rIUvQFpAH8uKGkj9t7BK3B2v4z0OkFdSMLSUb2N36JvU/s72-c/Tunatic.png" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-5585963709434680329</guid><pubDate>Sun, 16 May 2010 21:19:00 +0000</pubDate><atom:updated>2010-05-16T23:19:41.157+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">C++</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - C++ e Objective-C - Parte 15</title><description>&lt;!-- &lt;EdIndex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Eccoci finalmente all&#39;ultima parte della Guida all&#39;Objective-C. L&#39;argomento trattato oggi è l&#39;uso di C++ e Objective-C.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a questo &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html#//apple_ref/doc/uid/TP30001163-CH22-SW1&quot; title=&quot;Articolo originale in Inglese&quot;&gt;link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questa guida potrebbe interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;/div&gt;&lt;hr /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;h2&gt;Usare C++ Con Objective-C&lt;/h2&gt;&lt;div&gt;Il compilatore Objective-C di Apple ti permette di mixare liberamente C++ e Objective-C nello stesso file sorgente. Questo linguaggio ibrido Objective-C/C++ è chiamato Objective-C++. Con esso puoi fare uso di librerie C++ esistenti dalle tue applicazioni Objective-C.&lt;/div&gt;&lt;h2&gt;Mixare Caratteristiche di Linguaggio Objective-C e C++&lt;/h2&gt;&lt;div&gt;In Objective-C++, puoi chiamare metodi da l&#39;uno o l&#39;altro linguaggio, nel codice C++ e nei metodi Objective-C. I puntatori ad oggetti in uno o l&#39;altro linguaggio sono solo puntatori, e come tali possono essere usati ovunque. Ad esempio, puoi includere puntatori a oggetti Objective-C come membri dati di classi C++, e puoi includere puntatori ad oggetti C++ come variabili di istanza di classi Objective-C.&lt;br /&gt;
Il listato 14-1 illustra questo.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Nota:&lt;/b&gt; Xcode richiede che i nomi dei files abbiano un&#39;estensione &quot;.mm&quot; per le estensioni Objective-C++ per poter essere abilitate dal compilatore.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Listato 14-1&lt;/b&gt;  Usare C++ ed istanze Objective-C come variabili di istanza&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;/* Hello.mm&lt;br /&gt;
&lt;br /&gt;
 * Compila con: g++ -x objective-c++ -framework Foundation Hello.mm  -o hello&lt;br /&gt;
&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
#import &lt;Foundation/Foundation.h&gt;&lt;br /&gt;
&lt;br /&gt;
class Hello {&lt;br /&gt;
&lt;br /&gt;
    private:&lt;br /&gt;
&lt;br /&gt;
        id greeting_text;  // Contiene una NSString&lt;br /&gt;
&lt;br /&gt;
    public:&lt;br /&gt;
&lt;br /&gt;
        Hello() {&lt;br /&gt;
&lt;br /&gt;
            greeting_text = @&quot;Hello, world!&quot;;&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        Hello(const char* initial_greeting_text) {&lt;br /&gt;
&lt;br /&gt;
            greeting_text = [[NSString alloc] initWithUTF8String:initial_greeting_text];&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        void say_hello() {&lt;br /&gt;
&lt;br /&gt;
            printf(&quot;%s\n&quot;, [greeting_text UTF8String]);&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
@interface Greeting : NSObject {&lt;br /&gt;
&lt;br /&gt;
    @private&lt;br /&gt;
&lt;br /&gt;
        Hello *hello;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (id)init;&lt;br /&gt;
&lt;br /&gt;
- (void)dealloc;&lt;br /&gt;
&lt;br /&gt;
- (void)sayGreeting;&lt;br /&gt;
&lt;br /&gt;
- (void)sayGreeting:(Hello*)greeting;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
@implementation Greeting&lt;br /&gt;
&lt;br /&gt;
- (id)init {&lt;br /&gt;
&lt;br /&gt;
    if (self = [super init]) {&lt;br /&gt;
&lt;br /&gt;
        hello = new Hello();&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return self;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (void)dealloc {&lt;br /&gt;
&lt;br /&gt;
    delete hello;&lt;br /&gt;
&lt;br /&gt;
    [super dealloc];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (void)sayGreeting {&lt;br /&gt;
&lt;br /&gt;
    hello-&gt;say_hello();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (void)sayGreeting:(Hello*)greeting {&lt;br /&gt;
&lt;br /&gt;
    greeting-&gt;say_hello();&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
&lt;br /&gt;
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
    Greeting *greeting = [[Greeting alloc] init];&lt;br /&gt;
&lt;br /&gt;
    [greeting sayGreeting];                         // &gt; Hello,  world!&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
    Hello *hello = new Hello(&quot;Bonjour, monde!&quot;);&lt;br /&gt;
&lt;br /&gt;
    [greeting sayGreeting:hello];                   // &gt; Bonjour,  monde!&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
    delete hello;&lt;br /&gt;
&lt;br /&gt;
    [greeting release];&lt;br /&gt;
&lt;br /&gt;
    [pool release];&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Come puoi dichiarare strutture C in interfacce Objective-C, puoi anche dichiarare classi C++ in interfacce Objective-C. Come con le strutture C, le classi C++ definite dentro un&#39;interfaccia Objective-C hanno uno scope globale, non annidato entro la classe Objective-C. (ciò è coerente  con il modo in cui standard C (sebbene non C++) promuova le definizioni di strutture nidificate allo scope del file).&lt;br /&gt;
&lt;br /&gt;
Per permettervi di condizionare il vostro codice basato su una variante del linguaggio, il compilatore Objective-C++ definisce entrambe le costanti di preprocessore __clusplus e __OBJC__, come specificato dagli standards dei linguaggi C++ e Objective-C rispettivamente.&lt;br /&gt;
&lt;br /&gt;
Come detto precedentemente, Objective-C++ non permette di ereditare classi C++ dagli oggetti Objective-C, nè permette di ereditare classi Objective-C da oggetti C++.&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;class Base { /* ... */ };&lt;br /&gt;
&lt;br /&gt;
@interface ObjCClass: Base ... @end // ERROR!&lt;br /&gt;
&lt;br /&gt;
class Derived: public ObjCClass ... // ERROR!&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Diversamente dall&#39;Objective-C, gli oggetti in C++ sono tipati staticamente, con polimorfismo a runtime disponibile come caso eccezionale. I modelli oggetto dei due linguaggi sono quindi non direttamente compatibili. Più fondamentalmente, il layout degli oggetti Obj-C e C++ in memoria è mutuamente incompatibile, ciò significa che generalmente è impossibile creare un&#39;istanza di un oggetto che sarebbe valida dalla prospettiva di entrambi i linguaggi. Quindi, i due tipi di gerarchia non possono essere intercambiati.&lt;br /&gt;
&lt;br /&gt;
Puoi dichiarare una classe C++ dentro una dichiarazione di calsse Objective-C. Il compilatore tratta queste classi come se fossero state dichiarate nel namespace globale, come segue:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface Foo {&lt;br /&gt;
&lt;br /&gt;
 class Bar { ... } // OK&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Bar *barPtr; // OK&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Objective-C permette di usare strutture C (sia se dichiarate dentro una dichiarazione Objective-C sia se non dichiarate) come variabili di istanza.&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface Foo {&lt;br /&gt;
&lt;br /&gt;
   struct CStruct { ... };&lt;br /&gt;
&lt;br /&gt;
   struct CStruct bigIvar; // OK&lt;br /&gt;
&lt;br /&gt;
} ... @end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Su Mac OS X 10.4 e successivi, se imposti il flag del compilatore fobjc-call-cxx-cdtors, puoi usare istanze di classi C++ che contengono funzioni virtuali e costruttori non banali e decostruttori come variabili di istanza.( il flag fobjc-call-cxx-cdtors è impostato di default in gcc-4.2.) I Costruttori sono invocati nel metodo alloc (specificamente, dentro class_createInstance), in ordine di dichiarazione immediatamente dopo che l&#39;oggetto di cui sono membri è allocato. Il costruttore usato è il &quot;costruttore pubblico senza argomenti&quot;. I distruttori sono invocati nl metodo dealloc (specificamente, dentro object_dispose), in ordine inverso della dichiarazione immediatamente prima che l&#39;oggetto di cui sono membri è deallocato.&lt;br /&gt;
&lt;br /&gt;
Mac OS X v10.3 e precedenti: Le seguenti precauzioni si applicano solo a Mac OS X v10.3 e precedenti.&lt;br /&gt;
&lt;br /&gt;
Objective-C++ in modo simile si sforza di permettere a istanze di classi C++ di servire come variabili di istanza. Questo è possibile fintanto che la classe C+ in questione non ha funzioni membro virtuali definite. Se qualunque funzione membro virtuale fosse presente, la classe C++ potrebbe non servire come una variabile d&#39;istanza Objective-C.&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;#import &lt;Cocoa/Cocoa.h&gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
struct Class0 { void foo(); };&lt;br /&gt;
&lt;br /&gt;
struct Class1 { virtual void foo(); };&lt;br /&gt;
&lt;br /&gt;
struct Class2 { Class2(int i, int j); };&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
@interface Foo : NSObject {&lt;br /&gt;
&lt;br /&gt;
    Class0 class0;      // OK&lt;br /&gt;
&lt;br /&gt;
    Class1 class1;      // ERROR!&lt;br /&gt;
&lt;br /&gt;
    Class1 *ptr;        // OK—call &#39;ptr = new Class1()&#39; from Foo&#39;s init,&lt;br /&gt;
&lt;br /&gt;
                        // &#39;delete ptr&#39; from Foo&#39;s dealloc&lt;br /&gt;
&lt;br /&gt;
    Class2 class2;      // WARNING - constructor not called!&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;C++ richiede che ogni istanza di una classe che contiene funzioni virtuali contenga un puntatore adatto nella tavola delle funzioni virtuali. Comunque, il runtime dell&#39;Objective-C non può inizializzare il puntatore della tavola delle funzioni virtuali, perchè non è familiare con il modello degli oggetti C++. In modo analogo, il runtime di Objective-C non può spedire chiamate a costruttori C++ o decostruttori per quegli oggetti. Se una classe C++ ha qualsiasi costruttore definito da utente o distruttore, essi non sono chiamati. Il compilatore emette un warning in tali casi.&lt;br /&gt;
&lt;br /&gt;
Objective-C non ha una nozione di nasmespaces annidati. Non puoi dichiarare classi Objective-C dentro namespaces C++, nè puoi dichiarare namespaces dentro classi Objective-C.&lt;br /&gt;
&lt;br /&gt;
Classi Objective-C, protocolli, e categorie non possono essere dichiarati dentro un template C++, nè un template C++ può essere dichiarato nello scope di un&#39;interfaccia, protocollo o categoria Objective-C.&lt;br /&gt;
&lt;br /&gt;
Comunque, classi Objective-C potrebbero servire come parametri di template C++. Parametri dei template di C++ possono anche essere usati come riceventi o parametri (comunque non come selettori) in espressioni di messaggi Objective-C.&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;C++ Ambiguità Lessicali e Conflitti&lt;/h2&gt;&lt;div&gt;Ci sono pochi identificatori che sono definiti nei files header Objective-C che ogni programma Objective-C deve includere. Questi identificatori sono id, Class, SEL, IMP, e BOOL.&lt;br /&gt;
In un metodo Objective-C, Il compilatore pre-dichiara gli identificatori self e super, in modo simile alla parola chiave this in C++. Comunque, diversamente dalla parola chiave this in C++, self e super sono context-sensitive (sensibili al contesto); potrebbero essere usati come identificatori ordinari fuori ai metodi Objective-C.&lt;br /&gt;
&lt;br /&gt;
Nella lista dei parametri dei metodi dentro un protocollo, ci sono altre cinque parole chiave context-sensitive (oneway, in, out, inout, and bycopy). Queste non sono parole chiavi in altri contesti.&lt;br /&gt;
&lt;br /&gt;
Dal punto di vista di un programmatore Objective-C, C++ aggiunge parecchie nuove parole chiavi. Puoi usare ancora le parole chiavi C++ come parte di un selettore Objective-C, così l&#39;impatto non è troppo severo, ma non puoi usarle per nominare classi Objective-C o variabili di istanza. Ad esempio, anche se class è una parola chiave C++, puoi ancora usare il metodo class: di NSObject.&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;[foo class]; // OK&lt;/div&gt;&lt;div&gt;Comunque, dato che è una parola chiave, non puoi usare class come il nome di una variabile:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;NSObject *class; // Error&lt;/div&gt;&lt;div&gt;In Objective-C, i nomi per le classi e le categorie vivono in namespaces diversi. Che è, entrambi @interface foo e @interface(foo) possono esistere nello stesso codice sorgente. In Objective-C++, puoi anche avere una categoria i cui nomi combaciano con una classe o struttura C++.&lt;br /&gt;
Gli specificatori di protocollo e template usano la stessa sintassi per scopi diversi:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;id&lt;someProtocolName&gt; foo;&lt;br /&gt;
&lt;br /&gt;
TemplateType&lt;SomeTypeName&gt; bar;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Per evitare quest&#39;ambiguità, il compilatore non permette che id venga usato come nome di template.&lt;br /&gt;
&lt;br /&gt;
Infine, c&#39;è un&#39;ambiguità lessicale in C++ quando un&#39;etichetta è seguita da un&#39;espressione che menziona un nome globale, come in:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;label: ::global_name = 3;&lt;/div&gt;&lt;div&gt;Lo spazio dopo i primi due punti è richiesto. Objective-C++ aggiunge un caso simile, il quale richiede anch&#39;esso uno spazio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;receiver selector: ::global_c++_name;&lt;/div&gt;&lt;h2&gt;Limitazioni&lt;/h2&gt;&lt;div&gt;Objective-C++ non aggiunge caratteristiche di C++ alle classi Objective-C, né aggiunge caratteristiche Objective-C a classi C++. Ad esempio, non puoi usare la sintassi Objective-C per chiamare un oggetto C++, non puoi aggiungere costruttori o distruttori per un oggetto Objective-C, e non puoi usare le parole chiave this e self intercambiabilmente. Le gerarchie di classi sono separate; una classe C++ non può ereditare da una classe Objective-C, e una classe Objective-C non può ereditare da una classe C++. Inoltre la gestione delle eccezioni multi-language non è supportata. Cioè, un&#39;eccezione lanciata in codice Objective-C non può essere catturata nel codice C++, e un&#39;eccezione lanciata nel codice C++ non può essere catturata nel codice Objective-C. Per più informazioni sulle eccezioni in Objective-C, consultate &quot;Gestione delle Eccezioni&quot;.&lt;/div&gt;&lt;hr&gt;&lt;/span&gt; &lt;!-- &lt;/EdIndex&gt; --&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/05/guida-objective-c-in-italiano-c-e.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-4500755888689161544</guid><pubDate>Thu, 06 May 2010 14:44:00 +0000</pubDate><atom:updated>2010-05-06T16:44:50.299+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">messaggi remoti</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">remote messaging</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - Messaggi Remoti  - Parte 14</title><description>&lt;!-- &lt;EdIndex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Eccoci alla penultima parte della Guida in Italiano alla programmazione in Objective-C, la quattordicesima per l&#39;esattezza, nella quale parleremo di un&#39;importante argomento che è il Remote Messaging.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2&quot; title=&quot;Guida Originale in Inglese&quot;&gt;questo link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questo articolo può interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;/div&gt;&lt;hr /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;h2&gt;Remote Messaging&lt;/h2&gt;&lt;div&gt;Come la maggior parte degli altri linguaggi di programmazione, l&#39;Objective-C è stato inizialmente progettato per programmi che sono eseguiti come un singolo processo in un singolo spazio di indirizzi.&lt;br /&gt;
&lt;br /&gt;
Tuttavia, il modello OO, dove la comunicazione prende posto tra unità relativamente auto-convenute attraverso messaggi che sono risolti a runtime, sembrerebbe ben adatto anche per la comunicazione tra processi. Non è difficile immaginare messaggi Objective-C tra oggetti che risiedono in diversi spazi di indirizzi (differenti compiti) o in diversi threads di esecuzione dello stesso compito.&lt;br /&gt;
&lt;br /&gt;
Per esempio, in una tipica interazione server-client, il compito del client  potrebbe inviare le sue richieste ad un oggetto designato nel server, ed il server potrebbe mirare a specifici oggetti del client per le notifiche ed altre informazioni che invia. O immaginate un&#39;applicazione interattiva che ha bisogno di fare molti calcoli per effettuare un comando dell&#39;utente. Potrebbe semplicemente mostrare un dialogo che dice che l&#39;utente deve aspettare mentre è occupata, o potrebbe isolare il lavoro di processo in compiti subordinati, lasciando la parte principale dell&#39;applicazione libera di accettare input dall&#39;utente. Gli oggetti nei due compiti, comunicherebbero attraverso messaggi Objective-C.&lt;/div&gt;&lt;h2&gt;Oggetti Distribuiti&lt;/h2&gt;&lt;div&gt;I messaggi remoti in Objective-C richiedono un sistema di runtime che possa stabilire connessioni tra oggetti in diversi spazi di indirizzi, riconoscere quando un messaggio è inteso per un oggetto in uno spazio di indirizzi remoto, e trasferire i dati da uno spazio di indirizzi ad un altro. Deve anche mediare tra i programmi (schedules) separati dei due compiti; deve mantenere i messaggi finché i loro riceventi remoti siano liberi di rispondergli.&lt;br /&gt;
&lt;br /&gt;
Cocoa include un&#39;architettura ad oggetti distribuiti che è essenziale per questo tipo di estensioni del sistema di runtime. Usando gli oggetti distribuiti, puoi inviare messaggi Objective-C ad oggetti in altre attività o avere messaggi eseguiti in altri threads della stessa attività. (Quando i messaggi remoti sono inviati tra due threads della stessa attività, i threads sono trattati esattamente come threads di attività diverse). Nota che il sistema di oggetti distribuiti di Cocoa è costruito in cima al sistema di runtime; non altera il comportamento fondamentale dei tuoi oggetti Cocoa.&lt;br /&gt;
&lt;br /&gt;
Per inviare un messaggio remoto, un&#39;applicazione deve prima stabilire una connessione con il ricevente remoto. Stabilire la connessione da all&#39;applicazione un proxy per l&#39;oggetto remoto nel suo proprio spazio di indirizzi. Esso allora comunica con l&#39;oggetto remoto attraverso il proxy. Il proxy assume l&#39;identità dell&#39;oggetto remoto; non ha identità di suo. L&#39;applicazione è in grado di riguardare il proxy come se fosse l&#39;oggetto remoto; Per la maggior parte degli scopi, è l&#39;oggetto remoto.&lt;br /&gt;
&lt;br /&gt;
Inviare messaggi remoti è illustrato in figura 13-1, dove l&#39;oggetto A comunica con l&#39;oggetto B attraverso un proxy, e i messaggi per B aspettano in una coda finché B è pronto a rispondergli.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Figura 13-1&lt;/b&gt; Messaggi Remoti &lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu-liyfHF0JGQopPTIqwmVgS1RlCuuIGE-xwQH7KOqnea7ufWVWdjHH6lCSEC_k9weHoWhop1s6YHE1MbL_l6HjIHkoe2licZLQmqoqilNBmKp-x-DZqN4i4TxRy40Y3kihqY5JfiuB7hQ/s1600/messageproxy.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu-liyfHF0JGQopPTIqwmVgS1RlCuuIGE-xwQH7KOqnea7ufWVWdjHH6lCSEC_k9weHoWhop1s6YHE1MbL_l6HjIHkoe2licZLQmqoqilNBmKp-x-DZqN4i4TxRy40Y3kihqY5JfiuB7hQ/s320/messageproxy.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Il mittente e il ricevente sono in attività differenti e sono programmate (scheduled) indipendentemente l&#39;una dall&#39;altra. Quindi non c&#39;è garanzia che il ricevente sia libero di accettare un messaggio quando il mittente è pronto ad inviarlo. Quindi, i messaggi che arrivano sono posti in una coda e recuperati alla convenienza dell&#39;applicazione ricevente.&lt;br /&gt;
&lt;br /&gt;
Un proxy non agisce per conto dell&#39;oggetto remoto o deve accedere alla sua classe. Non è una copia dell&#39;oggetto ma un leggero sostituto per esso. In un certo senso, è trasparente; semplicemente passa i messaggi che riceve al ricevente remoto e gestisce la comunicazione tra i processi. La sua funzione principale è fornire un indirizzo locale per un oggetto che altrimenti non ne avrebbe uno. Un proxy non è totalmente trasparente. Per istanza, un proxy non ti permette di impostare e ottenere direttamente le variabili di istanza di un oggetto.&lt;br /&gt;
&lt;br /&gt;
Un ricevente remoto è tipicamente anonimo. La sua classe è nascosta dentro l&#39;applicazione remota. L&#39;applicazione mittente non ha bisogno di conoscere come è progettata l&#39;applicazione o che classi usa. Non ha bisogno di usare le stesse classi. Tutto ciò che gli serve sapere è a quali messaggi l&#39;oggetto remoto risponde.&lt;br /&gt;
&lt;br /&gt;
A causa di ciò, un oggetto che è designato per ricevere messaggi remoti, annuncia la sua interfaccia in un protocollo formale. Entrambe le applicazioni mittente e ricevente, dichiarano il protocollo - entrambe importano la stessa dichiarazione di protocollo. L&#39;applicazione ricevente lo dichiara perché l&#39;oggetto remoto deve aderire al protocollo. L&#39;applicazione mittente lo dichiara per informare il compilatore dei messaggi che invia e per questo, potrebbe usare il metodo conformsToProtocol: e la direttiva @protocol() per testare il ricevente remoto. L&#39;applicazione mittente non deve implementare alcuno dei metodi del protocollo; essa dichiara il protocollo solo perché il protocollo inizia i messaggi al ricevente remoto.&lt;/div&gt;&lt;h2&gt;Language Support&lt;/h2&gt;&lt;div&gt;I messaggi remoti emettono non solo molte intriganti possibilità per la progettazione di programmi, emettono anche alcuni interessanti problemi per il linguaggio. La maggior parte dei problemi sono collegati all&#39;efficienza dei messaggi remoti e al grado di separazione che due attività dovrebbero mantenere mentre comunicano l&#39;un l&#39;altra.&lt;br /&gt;
&lt;br /&gt;
Quindi quei programmatori possono dare istruzioni esplicite a riguardo l&#39;intento di usare messaggi remoti, l&#39;Objective-C definisce sei qualificatori di tipo che possono essere usati dichiarando metodi in un protocollo formale:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;  oneway&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;  in&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;  out&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;  inout&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;  bycopy&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;  byref&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;Questi modificatori sono ristretti a protocolli formali; non possono essere usati in una dichiarazione di classe o di categoria. Comunque se una classe o una categoria adottano un protocollo, la sua implementazione dei metodi del protocollo può usare gli stessi modificatori che sono usati per dichiarare i metodi.  La sezione seguente spiegherà come sono usati questi modificatori. &lt;/div&gt;&lt;h2&gt;Messaggi Sincroni e Asincroni&lt;/h2&gt;&lt;div&gt;Considerate prima un metodo con solo un semplice valore di ritorno:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (BOOL)canDance;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Quando un messaggio canDance è inviato ad un ricevente nella stessa applicazione, il metodo è invocato ed il valore di ritorno fornito direttamente al mittente. Ma quando il ricevente è in un&#39;applicazione remota, sono richiesti due messaggi di fondo - uno per ottenere l&#39;oggetto remoto per invocare il metodo, e l&#39;altro messaggio per inviare indietro il risultato del calcolo remoto. Questo è illustrato nella figura sotto:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Figura 13-2&lt;/b&gt;  Messaggio Round-Trip&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp3GWwgG776s0xvwuB9l5WbNyIs5CyGAT_70kF0u0PQCBxlVLm11mrswJ6u9NIW75q8GM7HFKWlyJBqA1P1DPDGYm1ghk-A0RBZjNSWiLJOTukY6roodNTjjuD5QvANhI_L9mibUd8nckE/s1600/messagingproxyreturn.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp3GWwgG776s0xvwuB9l5WbNyIs5CyGAT_70kF0u0PQCBxlVLm11mrswJ6u9NIW75q8GM7HFKWlyJBqA1P1DPDGYm1ghk-A0RBZjNSWiLJOTukY6roodNTjjuD5QvANhI_L9mibUd8nckE/s320/messagingproxyreturn.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
La maggior parte dei messaggi remoti, sono alla base, chiamate a procedure remote bi direzionali (o round-trip) come questo. L&#39;applicazione mittente aspetta l&#39;applicazione ricevente per invocare il metodo, completa la sua elaborazione, e invia indietro un&#39;indicazione che ha finito, insieme con qualunque informazione di ritorno richiesta. Aspettando che il ricevente finisca, anche se non è restituita alcuna informazione, ha il vantaggio di coordinare le due applicazioni comunicanti, di tenerle entrambe &quot;in sync&quot;. Per questo motivo, i messaggi round-trip sono spesso chiamati sincroni. I messaggi sono sincroni di default.&lt;br /&gt;
&lt;br /&gt;
Comunque, non è sempre necessario o non è sempre una buona idea aspettare una risposta. A volte è sufficiente spedire i messaggi remoti e ritornare, permettendo al ricevente di ottenere la sua attività quando può. Nel frattempo, il mittente può andare avanti su altre cose.   L&#39;Objective-C fornisce un modificatore di tipo di ritorno, oneway, per indicare che un metodo è usato solo per messaggi asincroni: &lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (oneway void)waltzAtWill;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Anche se oneway è un qualificatore di tipo (come const) e può essere usato in combinazione con un nome di tipo specifico, come oneway float o oneway id, l&#39;unica combinazione che ha senso è oneway void. Un messaggio asincrono non può avere un valore di ritorno valido.&lt;/div&gt;&lt;h2&gt;Argomenti Puntatore&lt;/h2&gt;&lt;div&gt;Consideriamo metodi che prendono argomenti puntatore. Un puntatore può essere usato per passare informazioni al ricevente tramite riferimento. Quando invocato, il metodo guarda a cosa è memorizzato nell&#39;indirizzo passato.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- setTune:(struct tune *)aSong&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;tune = *aSong;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Lo stesso tipo di argomento può essere usato anche per restituire informazioni tramite riferimento. Il metodo usa il puntatore per trovare dove potrebbe mettere le informazioni richieste nel messaggio.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- getTune:(struct tune *)theSong&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;*theSong = tune;&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Il modo in cui è usato il puntatore crea una differenza in come il messaggio remoto è effettuato. In nessun caso il puntatore può semplicemente essere passato senza cambi all&#39;oggetto remoto; esso punta a una locazione di memoria nello spazio di indirizzi del mittente e non sarebbe significativa nello spazio di indirizzi del ricevente remoto. Il sistema di runtime per i messaggi remoti deve fare alcune regolazioni dietro le scene.&lt;br /&gt;
&lt;br /&gt;
Se l&#39;argomento è usato per passare informazioni per riferimento, il sistema di runtime deve dereferenziare il puntatore, spedire il valore a cui esso punta all&#39;applicazione remota, memorizzare il valore in un indirizzo locale di quell&#39;applicazione e passare l&#39;indirizzo al ricevente remoto.&lt;br /&gt;
&lt;br /&gt;
Se d&#39;altra parte, il puntatore è usato per restituire informazioni per riferimento, il valore a cui punta non deve essere inviato all&#39;altra applicazione. Invece, un valore dall&#39;altra applicazione deve essere rispedito indietro e scritto nella locazione indicata dal puntatore.&lt;br /&gt;
&lt;br /&gt;
Nel primo caso, l&#39;informazione è passata sulla prima &quot;gamba&quot; del round trip. Nel secondo caso, l&#39;informazione è restituita sulla seconda &quot;gamba&quot; del round trip. Poiché questi casi risultano in molte azioni diverse sulla parte del sistema di runtime per i messaggi remoti, l&#39;Objective-C fornisce modificatori di tipo che chiarificano le intenzioni del programmatore:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Il modificatore di tipo &quot;in&quot; indica che l&#39;informazione è stata passata in un messaggio:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codice&quot;&gt;- setTune:(in struct tune *)aSong;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Il modificatore &quot;out&quot; indica che un argomento è stato usato per restituire informazione per riferimento:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codice&quot;&gt;- getTune:(out struct tune *)theSong;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;Un terzo modificatore, &quot;inout&quot;, indica che un argomento è usato sia per fornire informazioni sia per ri-ottenerle:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codice&quot;&gt;- adjustTune:(inout struct tune *)aSong;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;Il Sistema di oggetti distribuiti di Cocoa prende &quot;inout&quot; come modificatore di default per tutti gli argomenti puntatori tranne quelli dichiarati const, per i quali il default è &quot;in&quot;. &quot;inout&quot; è l&#39;assunzione più sicura ma anche quella che consuma più tempo dato che richiede il passaggio di informazioni in entrambe le direzioni. Il solo modificatore che ha senso per gli argomenti passati per valore (non puntatori) è &quot;in&quot;. Mentre &quot;in&quot; può essere usato con qualunque tipo di argomento, &quot;out&quot; e &quot;inout&quot; hanno senso solo per i puntatori.&lt;br /&gt;
&lt;br /&gt;
In C, i puntatori sono a volte usati per rappresentare valori compisiti. Per esempio, una stringa è rappresentata come un puntatore a carattere (char *). Sebbene nella notazione e implementazione c&#39;è un livello di indirezione qui, nel concetto non c&#39;è. Concettualmente, una stringa è un&#39;entità di per se, non un puntatore a qualcos&#39;altro.  In casi come questi, il sistema di oggetti distribuiti dereferenzia automaticamente il puntatore e passa qualsiasi cosa puntata, per valore. Quindi, i modificatori &quot;out&quot; ed &quot;inout&quot; non hanno senso con semplici puntatori a carattere. Ci vuole un livello aggiuntivo di indirezione in un messaggio remoto per passare o restituire una stringa per riferimento:   &lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- getTuneTitle:(out char **)theTitle;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
è vero lo stesso per gli oggetti:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- adjustRectangle:(inout Rectangle **)theRect;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Queste convinzioni sono applicate a runtime, non dal compilatore.&lt;/div&gt;&lt;h2&gt;Proxies e Copie&lt;/h2&gt;&lt;div&gt;Finalmente, consideriamo un metodo che prende un oggetto come argomento:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- danceWith:(id)aPartner;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Un messaggio danceWith: passa un id di un oggetto al ricevente. Se il mittente ed il ricevente sono nella stessa applicazione, entrambi sarebbero in grado di riferirsi allo stesso oggetto aPartner.&lt;br /&gt;
&lt;br /&gt;
Questo è vero anche se il ricevente è in un&#39;applicazione remota, tranne se il ricevente ha bisogno di riferirsi all&#39;oggetto attraverso un proxy (dato che l&#39;oggetto non è nel suo spazio di indirizzi). Il puntatore che danceWith: consegna ad un ricevente remoto è di fatto un puntatore al proxy. I messaggi inviati al proxy sarebbero passati attraverso la connessione all&#39;oggetto reale e qualsiasi informazione di ritorno sarebbe passata indietro all&#39;applicazione remota.&lt;br /&gt;
&lt;br /&gt;
Ci sono volte, quando i proxies potrebbero essere inutilmente inefficienti, quando è meglio inviare una copia dell&#39;oggetto ad un processo remoto così che esso possa interagirvi direttamente nel suo proprio spazio di indirizzi. Per dare ai programmatori un modo per indicare che questo è inteso, l&#39;Objective-C fornisce un modificatore di tipo bycopy: &lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- danceWith:(bycopy id)aClone;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
bycopy può essere usato anche per i valori di ritorno:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (bycopy)dancer;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Può essere usato in modo simile con &quot;out&quot; per indicare che un oggetto restituito per riferimento dovrebbe essere copiato piuttosto che consegnato nella forma di un proxy:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- getDancer:(bycopy out id *)theDancer;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Nota:&amp;lt;/b&amp;gt; Quando una copia di un oggetto è passata ad un&#39;altra applicazione, non può essere anonimo. L&#39;applicazione che riceve l&#39;oggetto deve avere la classe dell&#39;oggetto caricata nel suo spazio di indirizzi.&lt;br /&gt;
&lt;br /&gt;
bycopy ha molto più senso per certe classi - classi che contengono una collezione di altri oggetti - spesso queste classi sono scritte in modo che una copia è inviata ad un ricevente remoto, invece del solito riferimento. Puoi sovrascrivere questo comportamento tramite byref, comunque, quindi specificando che gli oggetti passati ad un metodo o gli oggetti restituiti da un metodo dovrebbero essere passati o restituiti per riferimento. Dato che passare per riferimento  è il comportamento di default per la grande maggioranza degli oggetti Objective-C,  farete raramente uso della parola chiave byref.&lt;br /&gt;
&lt;br /&gt;
L&#39;unico tipo che ha senso modificare per bycopy o byrefè un oggetto, se tipato dinamicamente id o tipato staticamente da un nome di classe.&lt;br /&gt;
&lt;br /&gt;
Sebbene bycopy e byref non possono essere usati in una dichiarazione di classe o categoria, possono essere usati in un protocollo formale. Ad esempio, potresti scrivere un protocollo formale foo come segue:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@Protocol foo&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;- (bycopy)array;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;@end  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Una classe o categoria può allora adottare il tuo protocollo foo. Questo ti permette di costruire protocolli in modo che forniscano suggerimenti su come gli oggetti dovrebbero essere passati e restituiti dai metodi descritti dal protocollo.&lt;/div&gt;&lt;hr /&gt;&lt;div&gt;&lt;/div&gt;&lt;h2&gt;Fine Parte 14&lt;/h2&gt;&lt;div&gt;Finisce qui il quattordicesimo articolo di questa Guida dedicato al Threading. Il prossimo, sarà l&#39;ultimo, e parlerà dell&#39;uso di codice C++ con Objective-C; quindi come utilizzare librerie C++ nelle vostre applicazioni Objective-C.&lt;br /&gt;
&lt;br /&gt;
Segnalatemi eventuali errori, o commentate l&#39;articolo se l&#39;avete trovato utile. Iscrivetevi ai feed del blog per essere sempre aggiornati automaticamente ogni volta che saranno disponibili nuovi contenuti. Nella barra laterale del blog potete trovare l&#39;elenco di tutti gli articoli di questa guida. &lt;/div&gt;&lt;/span&gt; &lt;!-- &lt;/EdIndex&gt; --&gt; &lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/05/guida-objective-c-in-italiano-messaggi.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-1201116424902591558</guid><pubDate>Wed, 05 May 2010 12:06:00 +0000</pubDate><atom:updated>2010-05-05T14:06:06.267+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">threads</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - I Threads - Parte 13</title><description>&lt;!-- &lt;EdIndex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align:justify;&quot;&gt;Siamo giunti alla tredicesima parte della Guida in Italiano alla programmazione in Objective-C, oggi parleremo brevemente dei Threads.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2&quot; title=&quot;Guida Originale in Inglese&quot;&gt;questo link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questo articolo può interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;br /&gt;
&lt;/div&gt;&lt;hr&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;h2&gt;Threading&lt;/h2&gt;&lt;div&gt;L&#39;Objective-C fornisce supporto per la sincronizzazione dei thread e la gestione delle eccezioni. Per attivare il supporto per queste caratteristiche, usate l&#39;interruttore -fobjc-exceptions di GNU Compiler Collection (GCC) versione 3.3 e successive.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Nota:&lt;/b&gt; Usando l&#39;una o l&#39;altra di queste caratteristiche in un programma, rende l&#39;applicazione eseguibile solo in Mac OS X v10.3 e successivi poichè il supporto di runtime per la gestione delle eccezioni e la sincronizzazione non sono presenti in versioni precedenti del software.&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Sincronizzare l&#39;esecuzione dei Thread&lt;/h2&gt;&lt;div&gt;L&#39;Objective-C supportail multithreading nelle applicazioni. Questo vuol dire che i threads possono provare a modificare lo stesso oggetto allo stesso tempo, una situazione che può causare seri problemi in un programma. Per proteggere sezioni di codice dall&#39;essere eseguite da più di un thread alla volta, l&#39;Objective-C fornisce la direttiva @synchronized().&lt;br /&gt;
&lt;br /&gt;
La direttiva @synchronized()chiude una sezione di codice per l&#39;uso da un singolo thread. Gli altri threads sono bloccati finchè il thread esce dal codice protetto; che è, quando l&#39;esecuzione continua dopo l&#39;ultimo statement del blocco @synchronized().&lt;br /&gt;
&lt;br /&gt;
La direttiva @sinchronized prende come suoi soli argomenti qualunque oggetto Objective-C incluso self. Quest&#39;oggetto è conosciuto come semaforo di esclusione reciproca o mutex. Esso permette ad un thread di bloccare una sezione di codice per prevenirne l&#39;uso da altri threads. Dovresti separare i semafori per proteggere diverse sezioni critiche di un programma. è più sicuro creare tutti oggetti mutuamente esclusivi prima che l&#39;applicazione diventi multithreaded per evitare condizioni di competizione.&lt;br /&gt;
&lt;br /&gt;
Il listato 12-1 mostra un esempio di codice che usa self come il mutex per sincronizzare l&#39;accesso a metodi di istanza dell&#39;oggetto corrente. Puoi prendere un approccio simile per sincronizzare i metodi di classe della classe associata, usando l&#39;oggetto Class al posto di self. Nell&#39;ultimo caso, ovviamente, solo un thread alla volta può eseguire un metodo di classe perchè c&#39;è solo un oggetto di classe che è condiviso da tutti i chiamanti.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Listato 12-1&lt;/b&gt;  Bloccare un metodo usando self&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (void)criticalMethod&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
@synchronized(self) {&lt;br /&gt;
&lt;br /&gt;
// Critical code.&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Il listato 12-2 mostra un approccio generale. Prima di eseguire un processo critico, il codice ottiene un semaforo dalla classe Account e lo usa per chiudere sezioni critiche. La classe Account potrebbe creare il semaforo nel suo metodo initialize.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Listato 12-2&lt;/b&gt;  Bloccare un metodo usando un semaforo personalizzato&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Account *account = [Account accountFromString:[accountField stringValue]];&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Get the semaphore.&lt;br /&gt;
&lt;br /&gt;
id accountSemaphore = [Account semaphore];&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@synchronized(accountSemaphore) {&lt;br /&gt;
&lt;br /&gt;
// Critical code.&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;La caratteristica di sincronizzazione dell&#39;Objective-C supporta codice ricorsivo e rientrante. Un thread può usare un singolo semaforo molte volte, in una maniera ricorsiva; altri threads sono bloccati dall&#39;uso del semaforo finché il thread rilascia tutte le parti di codice bloccate ottenute da lui; che sarebbe, quando ogni blocco @synchronized() termina normalmente o tramite un&#39;eccezione.&lt;br /&gt;
&lt;br /&gt;
Quando il codice in un blocco @synchronized() lancia un&#39;eccezione, il runtime cattura l&#39;eccezione, rilascia il semaforo (così che il codice protetto possa essere eseguito da altri threads), e ri-lancia l&#39;eccezione al prossimo gestore di eventi.&lt;br /&gt;
&lt;/div&gt;&lt;hr&gt;&lt;h2&gt;Fine Parte 13&lt;/h2&gt;&lt;div&gt;Finisce qui il tredicesimo articolo di questa Guida dedicato al Threading. Siamo ormai quasi alla fine, e il prossimo post tratterà i messaggi remoti.&lt;br /&gt;
&lt;br /&gt;
Segnalatemi eventuali errori, o commentate l&#39;articolo se l&#39;avete trovato utile, anche per incentivarmi a continuare a pubblicare le mie traduzioni. Iscrivetevi ai feed del blog per essere sempre aggiornati automaticamente ogni volta che sono disponibili nuovi contenuti.&lt;br /&gt;
Nella barra laterale del blog potete trovare l&#39;elenco di tutti gli articoli di questa guida.&lt;br /&gt;
&lt;/div&gt;&lt;/span&gt; &lt;!-- &lt;/EdIndex&gt; --&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/05/guida-objective-c-in-italiano-i-threads.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-1140956975727503393</guid><pubDate>Tue, 04 May 2010 08:49:00 +0000</pubDate><atom:updated>2011-03-16T17:57:31.037+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Coda</category><category domain="http://www.blogger.com/atom/ns#">Deque</category><category domain="http://www.blogger.com/atom/ns#">java</category><category domain="http://www.blogger.com/atom/ns#">Liste concatenate</category><category domain="http://www.blogger.com/atom/ns#">Liste doppiamente concatenate</category><category domain="http://www.blogger.com/atom/ns#">Queue</category><category domain="http://www.blogger.com/atom/ns#">Strutture Dati</category><title>Esercizi Strutture Dati - Queue e Deque</title><description>Ecco la seconda parte degli esercizi di Strutture Dati (SD) di Laboratorio di Algoritmi e Strutture Dati (LASD) con il professor Salvatore &lt;a href=&quot;http://www.dia.unisa.it/professori/latorre/&quot;&gt;La Torre&lt;/a&gt;. Nel seguito di questo articolo ci saranno le strutture dati Queue (Coda) e Deque (Double ended Queue).&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 18.0pt; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: Times;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Esercizi su Queue&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;interface&lt;/span&gt; Queue&amp;lt;E&amp;gt;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Restituisce&lt;/u&gt; &lt;u&gt;il&lt;/u&gt; &lt;u&gt;numero&lt;/u&gt; &lt;u&gt;di&lt;/u&gt; &lt;u&gt;elementi&lt;/u&gt; &lt;u&gt;presenti&lt;/u&gt; &lt;u&gt;nella&lt;/u&gt; &lt;u&gt;coda&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; &lt;u&gt;un&lt;/u&gt; &lt;u&gt;int&lt;/u&gt; &lt;u&gt;da&lt;/u&gt; 0 &lt;u&gt;alla&lt;/u&gt; &lt;u&gt;lunghezza&lt;/u&gt; max &lt;u&gt;della&lt;/u&gt; &lt;u&gt;coda&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; size();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Controlla&lt;/u&gt; &lt;u&gt;se&lt;/u&gt; &lt;u&gt;la&lt;/u&gt; &lt;u&gt;coda&lt;/u&gt; è &lt;u&gt;vuota&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; true, &lt;u&gt;se&lt;/u&gt; &lt;u&gt;la&lt;/u&gt; &lt;u&gt;coda&lt;/u&gt; è &lt;u&gt;vuota&lt;/u&gt;, false &lt;u&gt;altrimenti&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;boolean&lt;/span&gt; isEmpty();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * Accede all&#39;elemento &lt;u&gt;sul&lt;/u&gt; front &lt;u&gt;della&lt;/u&gt; &lt;u&gt;coda&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; l&#39;elemento &lt;u&gt;al&lt;/u&gt; front &lt;u&gt;della&lt;/u&gt; &lt;u&gt;coda&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; EmptyQueueException &lt;u&gt;se&lt;/u&gt; &lt;u&gt;invocato&lt;/u&gt; &lt;u&gt;su&lt;/u&gt; &lt;u&gt;una&lt;/u&gt; &lt;u&gt;coda&lt;/u&gt; &lt;u&gt;vuota&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E front() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyQueueException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Inserisce&lt;/u&gt; &lt;u&gt;un&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;nel&lt;/u&gt; rear &lt;u&gt;della&lt;/u&gt; &lt;u&gt;coda&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; element l&#39;elemento &lt;u&gt;da&lt;/u&gt; &lt;u&gt;inserire&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; enqueue (E element);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Rimuove&lt;/u&gt; l&#39;elemento &lt;u&gt;sul&lt;/u&gt; front &lt;u&gt;della&lt;/u&gt; &lt;u&gt;coda&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; l&#39;elemento &lt;u&gt;rimosso&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; EmptyQueueException &lt;u&gt;se&lt;/u&gt; &lt;u&gt;invocato&lt;/u&gt; &lt;u&gt;su&lt;/u&gt; &lt;u&gt;una&lt;/u&gt; &lt;u&gt;coda&lt;/u&gt; &lt;u&gt;vuota&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E dequeue()&lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyQueueException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;Implementare l’interfaccia Queue (scrivere la classe &lt;span style=&quot;color: #205028;&quot;&gt;ArrayQueue&lt;/span&gt;) usando un array di lunghezza fissata &lt;/span&gt;&lt;span style=&quot;color: #3d6c27; font-family: &#39;Apple Symbols&#39;;&quot;&gt;􏰁􏰁&lt;/span&gt;&lt;span style=&quot;color: #3d6c27; font-family: Wingdings;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7e5313; font-family: Helvetica;&quot;&gt;public static final int CAPACITY = 1024;&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #b6881e; font-family: &#39;Apple Symbols&#39;;&quot;&gt;􏰀&lt;/span&gt;&lt;span style=&quot;color: #b6881e; font-family: Wingdings;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;Implementare Queue in modo che la coda piena invece della &lt;span style=&quot;color: #d4ac26;&quot;&gt;FullQueueException &lt;/span&gt;causa un aumento della taglia della coda&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; ArrayQueue&amp;lt;E&amp;gt; &lt;span style=&quot;color: #801755;&quot;&gt;implements&lt;/span&gt; Queue&amp;lt;E&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;final&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;CAPACITY&lt;/span&gt; = 1024;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;,&lt;span style=&quot;color: #1019c0;&quot;&gt;r&lt;/span&gt;,&lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt;,&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;;&lt;span style=&quot;color: #1019c0;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; E &lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt;[];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; ArrayQueue()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;this&lt;/span&gt;(&lt;span style=&quot;color: #1019c0;&quot;&gt;CAPACITY&lt;/span&gt;);&lt;span style=&quot;color: #1019c0;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; ArrayQueue(&lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; cap)&lt;span style=&quot;color: #646464;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt; = cap;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;=&lt;span style=&quot;color: #1019c0;&quot;&gt;r&lt;/span&gt;=&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;=0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt; = (E[])&lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; Object[&lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; size() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;boolean&lt;/span&gt; isEmpty() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;==&lt;span style=&quot;color: #1019c0;&quot;&gt;r&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E front() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyQueueException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyQueueException(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Coda Vuota!&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt;[&lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; enqueue(E element)&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt; == &lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt;-1)&lt;span style=&quot;color: #1019c0;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; E nuovaCoda[] = (E[])&lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; Object[&lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt;*2];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nuovaCoda[i]=&lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt;[(&lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;+i)%&lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;=0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;r&lt;/span&gt;=&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt; *=2;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt; = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt; = nuovaCoda;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; nuovaCoda = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt;[&lt;span style=&quot;color: #1019c0;&quot;&gt;r&lt;/span&gt;] = element;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;r&lt;/span&gt; = (&lt;span style=&quot;color: #1019c0;&quot;&gt;r&lt;/span&gt;+1)%&lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E dequeue() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyQueueException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyQueueException(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Coda Vuota!&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt;[&lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt;[&lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;] = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt; = (&lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;+1)%&lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; String toString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; String response = &lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;ArrayQueue Elements:[ &quot;&lt;/span&gt;;&lt;span style=&quot;color: #2d21f8;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; i = 0; i&amp;lt;&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; response += ((i+1)+&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;°&quot;&lt;/span&gt;+&lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt;[(&lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;+i)% &lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt;]+&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot; &quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; response+= &lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;] size:&quot;&lt;/span&gt;+size()+&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot; capacity: &quot;&lt;/span&gt;+&lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; response;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E extract(&lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; k) &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt;&amp;nbsp; NotEnoughElements&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (size() &amp;lt; k+1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; NotEnoughElements(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;La Coda non contiene abbastanza elementi!&quot;&lt;/span&gt;);&lt;span style=&quot;color: #2d21f8;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;coda&lt;/span&gt;[(&lt;span style=&quot;color: #1019c0;&quot;&gt;f&lt;/span&gt;+k)%&lt;span style=&quot;color: #1019c0;&quot;&gt;capacity&lt;/span&gt;];&lt;span style=&quot;color: #1019c0;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;Scrivere un programma che testi la vostra implementazione di Queue invocandone tutti i metodi&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; ArrayQueueTest&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; main(String[] args)&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; ArrayQueue&amp;lt;String&amp;gt; coda = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; ArrayQueue&amp;lt;String&amp;gt;(2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #3f7f5f;&quot;&gt;//QueueWithDeque&amp;lt;String&amp;gt; &lt;u&gt;coda&lt;/u&gt; = new QueueWithDeque&amp;lt;String&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #3f7f5f;&quot;&gt;//LinkedQueue&amp;lt;String&amp;gt; &lt;u&gt;coda&lt;/u&gt; = new LinkedQueue&amp;lt;String&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; coda.enqueue(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Marco&quot;&lt;/span&gt;);&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(coda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; coda.enqueue(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Rosaria&quot;&lt;/span&gt;);&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(coda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; coda.enqueue(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Francesco&quot;&lt;/span&gt;);&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(coda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; coda.enqueue(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Pippo&quot;&lt;/span&gt;);&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(coda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; coda.dequeue();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(coda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; coda.enqueue(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Giuseppe&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(coda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Front: &quot;&lt;/span&gt;+coda.front());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #3f7f5f;&quot;&gt;//System.out.println(&quot;3° &lt;u&gt;elem&lt;/u&gt; &lt;u&gt;dal&lt;/u&gt; front: &quot;+coda.extract(3));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; coda.dequeue();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(coda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; coda.dequeue();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(coda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; coda.dequeue();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(coda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; coda.dequeue();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; System.&lt;span style=&quot;color: #1019c0;&quot;&gt;out&lt;/span&gt;.println(coda);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 18.0pt; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: Times;&quot;&gt;Esercizi su Deque&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;interface&lt;/span&gt; Deque&amp;lt;E&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Restituisce&lt;/u&gt; &lt;u&gt;il&lt;/u&gt; &lt;u&gt;numero&lt;/u&gt; &lt;u&gt;di&lt;/u&gt; &lt;u&gt;elementi&lt;/u&gt; &lt;u&gt;contenuti&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; &lt;u&gt;un&lt;/u&gt; &lt;u&gt;valore&lt;/u&gt; &lt;u&gt;intero&lt;/u&gt; &amp;gt;= 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; size();&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Verifica&lt;/u&gt; &lt;u&gt;se&lt;/u&gt; &lt;u&gt;il&lt;/u&gt; &lt;u&gt;deque&lt;/u&gt; è &lt;u&gt;vuoto&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; true &lt;u&gt;se&lt;/u&gt; è &lt;u&gt;vuoto&lt;/u&gt;, false &lt;u&gt;altrimenti&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;boolean&lt;/span&gt; isEmpty();&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Restituisce&lt;/u&gt; &lt;u&gt;il&lt;/u&gt; &lt;u&gt;primo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;del&lt;/u&gt; &lt;u&gt;Deque&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; EmptyDequeException &lt;u&gt;se&lt;/u&gt; &lt;u&gt;invocato&lt;/u&gt; &lt;u&gt;su&lt;/u&gt; &lt;u&gt;Deque&lt;/u&gt; &lt;u&gt;vuoto&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E getFirst() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Restituisce&lt;/u&gt; l&#39;ultimo &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;del&lt;/u&gt; &lt;u&gt;Deque&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; EmptyDequeException &lt;u&gt;se&lt;/u&gt; &lt;u&gt;invocato&lt;/u&gt; &lt;u&gt;su&lt;/u&gt; &lt;u&gt;Deque&lt;/u&gt; &lt;u&gt;vuoto&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E getLast() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Aggiunge&lt;/u&gt; &lt;u&gt;un&lt;/u&gt; &lt;u&gt;nuovo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; all&#39;inizio &lt;u&gt;del&lt;/u&gt; &lt;u&gt;Deque&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; element &lt;u&gt;il&lt;/u&gt; &lt;u&gt;nuovo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;da&lt;/u&gt; &lt;u&gt;inserire&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; addFirst (E element);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Aggiunge&lt;/u&gt; &lt;u&gt;un&lt;/u&gt; &lt;u&gt;nuovo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;alla&lt;/u&gt; fine &lt;u&gt;del&lt;/u&gt; &lt;u&gt;Deque&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; element &lt;u&gt;il&lt;/u&gt; &lt;u&gt;nuovo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;da&lt;/u&gt; &lt;u&gt;inserire&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; addLast (E element);&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Rimuove&lt;/u&gt; e &lt;u&gt;restituisce&lt;/u&gt; &lt;u&gt;il&lt;/u&gt; &lt;u&gt;primo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;del&lt;/u&gt; &lt;u&gt;Deque&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; EmptyDequeException &lt;u&gt;se&lt;/u&gt; &lt;u&gt;invocato&lt;/u&gt; &lt;u&gt;su&lt;/u&gt; &lt;u&gt;Deque&lt;/u&gt; &lt;u&gt;vuoto&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E removeFirst() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Rimuove&lt;/u&gt; e &lt;u&gt;restituisce&lt;/u&gt; l&#39;ultimo &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;del&lt;/u&gt; &lt;u&gt;Deque&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; EmptyDequeException &lt;u&gt;se&lt;/u&gt; &lt;u&gt;invocato&lt;/u&gt; &lt;u&gt;su&lt;/u&gt; &lt;u&gt;Deque&lt;/u&gt; &lt;u&gt;vuoto&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E removeLast() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;Per implementare il TDA Deque usiamo una &lt;span style=&quot;color: #205028;&quot;&gt;lista doppiamente concatenata&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; DLNode&amp;lt;E&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; E &lt;span style=&quot;color: #1019c0;&quot;&gt;element&lt;/span&gt;;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; DLNode&amp;lt;E&amp;gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;prev&lt;/span&gt;, &lt;span style=&quot;color: #1019c0;&quot;&gt;next&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; DLNode()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;this&lt;/span&gt;(&lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;,&lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;,&lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;);&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; DLNode(E e, DLNode&amp;lt;E&amp;gt; p, DLNode&amp;lt;E&amp;gt; n)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;element&lt;/span&gt; = e;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;prev&lt;/span&gt; = p;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;next&lt;/span&gt; = n;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&lt;u&gt;metodi&lt;/u&gt; &lt;u&gt;accessori&lt;/u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E getElement()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;element&lt;/span&gt;;&lt;span style=&quot;color: #1019c0;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; DLNode&amp;lt;E&amp;gt; getPrev()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;prev&lt;/span&gt;;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; DLNode&amp;lt;E&amp;gt; getNext()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;next&lt;/span&gt;;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&lt;u&gt;metodi&lt;/u&gt; &lt;u&gt;modificatori&lt;/u&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; setElement(E e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;element&lt;/span&gt; = e;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; setPrev(DLNode&amp;lt;E&amp;gt; p)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;prev&lt;/span&gt; = p;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; setNext(DLNode&amp;lt;E&amp;gt; n)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;next&lt;/span&gt; = n;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;Implementare il TDA Deque (class MyDeque) con lista doppiamente concatenata&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; MyDeque&amp;lt;E&amp;gt; &lt;span style=&quot;color: #801755;&quot;&gt;implements&lt;/span&gt; Deque&amp;lt;E&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; DLNode&amp;lt;E&amp;gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;, &lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; MyDeque()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt; = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; DLNode&amp;lt;E&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt; = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; DLNode&amp;lt;E&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;.setNext(&lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;.setPrev(&lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt; = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt; == 0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E getFirst() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyDequeException(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Deck Vuoto!&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;.getNext().getElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E getLast() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyDequeException(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Deck Vuoto!&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;.getPrev().getElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; addFirst(E element)&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; DLNode&amp;lt;E&amp;gt; newNode = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; DLNode&amp;lt;E&amp;gt;(element,&lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;,&lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;.getNext());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;.getNext().setPrev(newNode);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;.setNext(newNode);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; addLast(E element)&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; DLNode&amp;lt;E&amp;gt; newNode = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt;&amp;nbsp;DLNode&amp;lt;E&amp;gt;(element,&lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;.getPrev(),&lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;.getPrev().setNext(newNode);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;.setPrev(newNode);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E removeFirst() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyDequeException(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Deck Vuoto! - Rimozione primo elem Impossibile&quot;&lt;/span&gt;);&lt;span style=&quot;color: #2d21f8;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;.getNext().getElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;.setNext(&lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;.getNext().getNext());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;.getNext().setPrev(&lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E removeLast() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyDequeException(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Deck Vuoto! - Rimozione ultimo elem Impossibile&quot;&lt;/span&gt;);&lt;span style=&quot;color: #2d21f8;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;.getPrev().getElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;.setPrev(&lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;.getPrev().getPrev());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;.getPrev().setNext(&lt;span style=&quot;color: #1019c0;&quot;&gt;trailer&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; String toString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; String risp = &lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Deque Elements: [ &quot;&lt;/span&gt;;&lt;span style=&quot;color: #2d21f8;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; DLNode&amp;lt;E&amp;gt; nodo = &lt;span style=&quot;color: #1019c0;&quot;&gt;header&lt;/span&gt;.getNext();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;; i++ )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; risp+= (i+1)+&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;°&quot;&lt;/span&gt;+nodo.getElement() + &lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; nodo = nodo.getNext();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; risp+= &lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;] size: &quot;&lt;/span&gt;+&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; risp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;Usare Deque per implementare Stack e Queue&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; StackWithDeque&amp;lt;E&amp;gt; &lt;span style=&quot;color: #801755;&quot;&gt;implements&lt;/span&gt; Stack&amp;lt;E&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; MyDeque&amp;lt;E&amp;gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; StackWithDeque()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt; = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; MyDeque&amp;lt;E&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.isEmpty();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E top() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyStackException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.getLast();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt; (EmptyDequeException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyStackException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E pop() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyStackException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.removeLast();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt; (EmptyDequeException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyStackException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; push(E o) &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; FullStackException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.addLast(o);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.size();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; String toString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt;(&lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.toString());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; QueueWithDeque&amp;lt;E&amp;gt; &lt;span style=&quot;color: #801755;&quot;&gt;implements&lt;/span&gt; Queue&amp;lt;E&amp;gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; MyDeque&amp;lt;E&amp;gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; QueueWithDeque()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt; = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; MyDeque&amp;lt;E&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.size();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.isEmpty();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E front() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyQueueException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.getFirst();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt;(EmptyDequeException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyQueueException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; enqueue(E element)&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.addLast(element);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E dequeue() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyQueueException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.removeFirst();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt;(EmptyDequeException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyQueueException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; String toString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Queue with &quot;&lt;/span&gt;+&lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.toString();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;Implementareilconcettodilistaconcatenatacome classe Java LinkedList&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; Node&amp;lt;E&amp;gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; E &lt;span style=&quot;color: #1019c0;&quot;&gt;element&lt;/span&gt;;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; Node&amp;lt;E&amp;gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;next&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; Node()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;this&lt;/span&gt;(&lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;,&lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;);&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; Node(E e, Node&amp;lt;E&amp;gt; n)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;element&lt;/span&gt; = e;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;next&lt;/span&gt; = n;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E getElement()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;element&lt;/span&gt;;&lt;span style=&quot;color: #1019c0;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; Node&amp;lt;E&amp;gt; getNext()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;next&lt;/span&gt;;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; setElement(E e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;element&lt;/span&gt; = e;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; setNext(Node&amp;lt;E&amp;gt; n)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;next&lt;/span&gt; = n;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; LinkedList&amp;lt;E&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; Node&amp;lt;E&amp;gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt;, &lt;span style=&quot;color: #1019c0;&quot;&gt;tail&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; LinkedList()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;tail&lt;/span&gt; = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; Node&amp;lt;E&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt; = &lt;span style=&quot;color: #1019c0;&quot;&gt;tail&lt;/span&gt;;&lt;span style=&quot;color: #1019c0;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt; = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Restituisce&lt;/u&gt; &lt;u&gt;il&lt;/u&gt; &lt;u&gt;numero&lt;/u&gt; &lt;u&gt;di&lt;/u&gt; &lt;u&gt;elementi&lt;/u&gt; &lt;u&gt;contenuti&lt;/u&gt; &lt;u&gt;nella&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; &lt;u&gt;un&lt;/u&gt; &lt;u&gt;valore&lt;/u&gt; &lt;u&gt;intero&lt;/u&gt; &amp;gt;= 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; size()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;;&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Verifica&lt;/u&gt; &lt;u&gt;se&lt;/u&gt; &lt;u&gt;la&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt; è &lt;u&gt;vuota&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; true &lt;u&gt;se&lt;/u&gt; è &lt;u&gt;vuota&lt;/u&gt;, false &lt;u&gt;altrimenti&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;boolean&lt;/span&gt; isEmpty()&lt;span style=&quot;color: #801755;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; (&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt; == 0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Aggiunge&lt;/u&gt; &lt;u&gt;un&lt;/u&gt; &lt;u&gt;nuovo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; all&#39;inizio &lt;u&gt;della&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; e &lt;u&gt;il&lt;/u&gt; &lt;u&gt;nuovo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;da&lt;/u&gt; &lt;u&gt;inserire&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; addFirst(E e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt; == 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt;.setElement(e);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; Node&amp;lt;E&amp;gt; newNode = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; Node&amp;lt;E&amp;gt;(e,&lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt; = newNode;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Aggiunge&lt;/u&gt; &lt;u&gt;un&lt;/u&gt; &lt;u&gt;nuovo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;alla&lt;/u&gt; fine &lt;u&gt;della&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; e &lt;u&gt;il&lt;/u&gt; &lt;u&gt;nuovo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;da&lt;/u&gt; &lt;u&gt;inserire&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; addLast(E e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt; == 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;tail&lt;/span&gt;.setElement(e);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; Node&amp;lt;E&amp;gt; newNode = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; Node&amp;lt;E&amp;gt;(e,&lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;tail&lt;/span&gt;.setNext(newNode);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;tail&lt;/span&gt; = newNode;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Rimuove&lt;/u&gt; e &lt;u&gt;restituisce&lt;/u&gt; &lt;u&gt;il&lt;/u&gt; &lt;u&gt;primo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;dalla&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; EmptyLinkedListException &lt;u&gt;se&lt;/u&gt; &lt;u&gt;invocato&lt;/u&gt; &lt;u&gt;sulla&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt; &lt;u&gt;vuota&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E removeFirst() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyLinkedListException&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyLinkedListException(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Lista Vuota!&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt; == 1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt;.getElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt;.setElement(&lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt;.getElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt; = &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt;.getNext();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Rimuove&lt;/u&gt; e &lt;u&gt;restituisce&lt;/u&gt; l&#39;ultimo &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;della&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; EmptyLinkedListException &lt;u&gt;se&lt;/u&gt; &lt;u&gt;invocato&lt;/u&gt; &lt;u&gt;su&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt; &lt;u&gt;vuota&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E removeLast() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyLinkedListException&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyLinkedListException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt; == 1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;tail&lt;/span&gt;.getElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;tail&lt;/span&gt;.setElement(&lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; Node&amp;lt;E&amp;gt; nodo = &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;-1; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (nodo.getNext().getNext() == &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp = nodo.getNext().getElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nodo.setNext(&lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;tail&lt;/span&gt; = nodo;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;--;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;else&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nodo = nodo.getNext();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; }&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Restituisce&lt;/u&gt; &lt;u&gt;il&lt;/u&gt; &lt;u&gt;primo&lt;/u&gt; &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;della&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; EmptyLinkedListException &lt;u&gt;se&lt;/u&gt; &lt;u&gt;invocato&lt;/u&gt; &lt;u&gt;su&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt; &lt;u&gt;vuota&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E getFirst() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyLinkedListException&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyLinkedListException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt;.getElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;u&gt;Restituisce&lt;/u&gt; l&#39;ultimo &lt;u&gt;elemento&lt;/u&gt; &lt;u&gt;della&lt;/u&gt; &lt;u&gt;lista&lt;/u&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; * &lt;/span&gt;&lt;span style=&quot;color: #7f9fbf; font-family: Monaco;&quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt; EmptyLinkedListException &lt;u&gt;se&lt;/u&gt; &lt;u&gt;invocato&lt;/u&gt; su lista vuota.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3f5fbf; font-family: Monaco;&quot;&gt;&amp;nbsp; */&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E getLast() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyLinkedListException&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;if&lt;/span&gt; (isEmpty())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyLinkedListException(&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;Lista Vuota!&quot;&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;tail&lt;/span&gt;.getElement();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; String toString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; String stringa = &lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;LinkedList Elements: [ &quot;&lt;/span&gt;;&lt;span style=&quot;color: #2d21f8;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; Node&amp;lt;E&amp;gt; nodo = &lt;span style=&quot;color: #1019c0;&quot;&gt;head&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; i=0; i&amp;lt;&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; stringa += nodo.getElement()+&lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot; &quot;&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; nodo = nodo.getNext();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; stringa += &lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;] size: &quot;&lt;/span&gt;+&lt;span style=&quot;color: #1019c0;&quot;&gt;size&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; stringa;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;ImplementareilTDAStackconlistaconcatenata&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3d6c27; font-family: &#39;Apple Symbols&#39;;&quot;&gt;􏰁&lt;/span&gt;&lt;span style=&quot;color: #3d6c27; font-family: Wingdings;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7e5313; font-family: Helvetica;&quot;&gt;Definire classe LinkedStack&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; LinkedStack&amp;lt;E&amp;gt; &lt;span style=&quot;color: #801755;&quot;&gt;implements&lt;/span&gt; Stack&amp;lt;E&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; LinkedList&amp;lt;E&amp;gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; LinkedStack()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt; = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; LinkedList&amp;lt;E&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;boolean&lt;/span&gt; isEmpty()&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.isEmpty();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E top() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyStackException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.getLast();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt; (EmptyLinkedListException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyStackException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E pop() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyStackException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.removeLast();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt; (EmptyLinkedListException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyStackException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; push(E o) &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; FullStackException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.addLast(o);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; size()&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.size();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; String toString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.toString();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;ImplementareilTDAQueueconlistaconcatenata&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #3d6c27; font-family: &#39;Apple Symbols&#39;;&quot;&gt;􏰁&lt;/span&gt;&lt;span style=&quot;color: #3d6c27; font-family: Wingdings;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #7e5313; font-family: Helvetica;&quot;&gt;Definire classe LinkedQueue&lt;/span&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; LinkedQueue&amp;lt;E&amp;gt; &lt;span style=&quot;color: #801755;&quot;&gt;implements&lt;/span&gt; Queue&amp;lt;E&amp;gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; LinkedList&amp;lt;E&amp;gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; LinkedQueue()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt; = &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; LinkedList&amp;lt;E&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; size() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.size();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;boolean&lt;/span&gt; isEmpty() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.isEmpty();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E front() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyQueueException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.getFirst();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt;(EmptyLinkedListException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyQueueException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; enqueue(E element) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.addLast(element);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E dequeue() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyQueueException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.removeFirst();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt;(EmptyLinkedListException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyQueueException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; String toString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #2d21f8;&quot;&gt;&quot;QUEUE with &quot;&lt;/span&gt;+&lt;span style=&quot;color: #1019c0;&quot;&gt;contenitore&lt;/span&gt;.toString();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #b6881e; font-family: &#39;Apple Symbols&#39;;&quot;&gt;􏰀&lt;/span&gt;&lt;span style=&quot;color: #b6881e; font-family: Wingdings;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: Helvetica;&quot;&gt;ImplementareilTDADequeconlisteconcatenate&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;color: #801755; font-family: Monaco;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt; &lt;span style=&quot;color: #801755;&quot;&gt;class&lt;/span&gt; LinkedDeque&amp;lt;E&amp;gt; &lt;span style=&quot;color: #801755;&quot;&gt;implements&lt;/span&gt; Deque&amp;lt;E&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;private&lt;/span&gt; LinkedList&amp;lt;E&amp;gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;lista&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;int&lt;/span&gt; size() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;lista&lt;/span&gt;.size();&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;boolean&lt;/span&gt; isEmpty() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #1019c0;&quot;&gt;lista&lt;/span&gt;.isEmpty();&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E getFirst() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;lista&lt;/span&gt;.getFirst();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt; (EmptyLinkedListException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyDequeException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E getLast() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;lista&lt;/span&gt;.getLast();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt; (EmptyLinkedListException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyDequeException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; addFirst(E element) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;lista&lt;/span&gt;.addFirst(element);&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;void&lt;/span&gt; addLast(E element) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #1019c0;&quot;&gt;lista&lt;/span&gt;.addLast(element);&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E removeFirst() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;lista&lt;/span&gt;.removeFirst();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt; (EmptyLinkedListException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyDequeException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #646464;&quot;&gt;@Override&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #801755;&quot;&gt;public&lt;/span&gt; E removeLast() &lt;span style=&quot;color: #801755;&quot;&gt;throws&lt;/span&gt; EmptyDequeException&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; E tmp = &lt;span style=&quot;color: #801755;&quot;&gt;null&lt;/span&gt;;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; tmp = &lt;span style=&quot;color: #1019c0;&quot;&gt;lista&lt;/span&gt;.removeLast();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;catch&lt;/span&gt; (EmptyLinkedListException e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;throw&lt;/span&gt; &lt;span style=&quot;color: #801755;&quot;&gt;new&lt;/span&gt; EmptyDequeException();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #801755;&quot;&gt;return&lt;/span&gt; tmp; &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-family: Monaco;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2011/03/esercizi-strutture-dati-queue-e-deque.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-4858453081536179059</guid><pubDate>Tue, 04 May 2010 00:35:00 +0000</pubDate><atom:updated>2010-05-04T02:35:10.226+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">gestione eccezioni</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - Le Eccezioni - Parte 12</title><description>&lt;!-- &lt;edindex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Siamo giunti alla dodicesima parte della Guida in Italiano alla programmazione in Objective-C, oggi parleremo della Gestione delle Eccezioni. Vi ricordo che potrete trovare tutti i links agli articoli di questa guida nella barra laterale del sito.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2&quot; title=&quot;Guida Originale in Inglese&quot;&gt;questo link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questo articolo può interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;/div&gt;&lt;hr /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;h2&gt;Gestione delle Eccezioni&lt;/h2&gt;&lt;div&gt;Il linguaggio Objective-C ha una sintassi per la gestione delle eccezioni simile a quella dei linguaggi Java and C++. Accoppiata con l&#39;uso di NSException, NSError, o classi personalizzate, puoi aggiungere una robusta gestione degli errori per i  tuoi programmi. Questo articolo fornisce un sommario della sintassi delle eccezioni e la loro gestione.&lt;/div&gt;&lt;h2&gt;Abilitare la gestione delle Eccezioni&lt;/h2&gt;&lt;div&gt;Usando gcc versione 3.3 e successive, Objective-C fornisce un supporto per la gestione delle eccezioni. Per attivare il supporto per queste caratteristiche usa l&#39;interruttore -fobjc-exceptions del GNU Compiler Collection (GCC) versione 3.3 e successivo. (Nota che questo rende l&#39;applicazione eseguibile solo su Mac OS X v10.3 e successivi poiché il supporto di runtime per la gestione delle eccezioni e la sincronizzazione non è presente in versioni precedenti del software).&lt;/div&gt;&lt;h2&gt;Gestione Eccezioni&lt;/h2&gt;&lt;div&gt;Un&#39;eccezione è una condizione speciale che interrompe il normale flusso d&#39;esecuzione del programma. Ci sono una varietà di motivi per cui un&#39;eccezione potrebbe essere generata dall&#39;hardware così come dal software. Esempi includono errori aritmetici come divisioni per zero, uderflow o overflow, chiamate a istruzioni indefinite, e tentare di accedere ad una collezione di elementi fuori dai suoi limiti.&lt;br /&gt;
&lt;br /&gt;
Il supporto delle eccezioni Objective-C gira attorno a quattro direttive di compilazione:  @try, @catch, @throw, e @finally:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Il codice che può lanciare potenzialmente un&#39;eccezione è racchiuso in un blocco @try.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Un blocco @catch() contiene la gestione logica delle eccezioni per le eccezioni lanciate in un blocco @try. Puoi avere blocchi @catch() multipli per catturare diversi tipi di eccezioni.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Un blocco @finally contiene codice che deve essere eseguito se un&#39;eccezione è o non è lanciata.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Usi la direttiva @throw per lanciare un&#39;eccezione, che è essenzialmente un&#39;oggetto Objective-C. Tipicamente usi un&#39;oggetto NSException, ma non è richiesto.&lt;/li&gt;
&lt;/ul&gt;L&#39;esempio sotto descrive un semplice algoritmo di gestione delle eccezioni: &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Cup *cup = [[Cup alloc] init];&lt;br /&gt;
&lt;br /&gt;
@try {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; [cup fill];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;@catch (NSException *exception) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;NSLog(@&quot;main: Caught %@: %@&quot;, [exception name], [exception reason]);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;@finally {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;[cup release];&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;&lt;h2&gt;Catturare Tipi Diversi di Eccezioni&lt;/h2&gt;&lt;div&gt;Per catturare un&#39;eccezione lanciata in un blocco @try, usa uno o più blocchi @catch() subito dopo il blocco @try. I blocchi @catch() dovrebbero essere ordinati dal più specifico al meno specifico. In questo modo potete adattare il processo di eccezioni come gruppi, come mostrato nel listato 11-1.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Listato 11-1&lt;/b&gt;  Un gestore di eccezioni &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@try {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
@catch (CustomException *ce) {  // 1&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
@catch (NSException *ne) {  // 2&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;// si eseguono le elaborazioni necessarie a questo livello.&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
@catch (id ue) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
@finally {&amp;nbsp;// 3&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;// si eseguono le elaborazini necessarie se è occorsa o meno un&#39;eccezione&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;br /&gt;
}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
La lista seguente descrive le linee di codice numerate:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Cattura il tipo di eccezione più specifica.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Cattura un tipo di eccezione più generico.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Esegue ogni elaborazione che deve essere eseguita se un&#39;eccezione è lanciata o meno.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;h2&gt;Lanciare Eccezioni&lt;/h2&gt;&lt;div&gt;Per lanciare un&#39;eccezione devi istanziare un oggetto con l&#39;informazione appropriata, come il nome dell&#39;eccezione e il motivo per cui è stata lanciata.&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;NSException *exception = [NSException exceptionWithName:@&quot;HotTeaException&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; reason:@&quot;The tea is too hot&quot;  userInfo:nil];&lt;br /&gt;
&lt;br /&gt;
@throw exception;  &lt;/div&gt;&lt;div&gt;&lt;b&gt;Importante:&lt;/b&gt; In molti ambienti, usare eccezioni è ragionevolmente ordinario. Ad esempio, potresti lanciare un&#39;eccezione per segnalare che una routine potrebbe non eseguirsi normalmente - come quando un file manca o i dati non possono essere analizzati correttamente. Le eccezioni consumano intensivamente risorse in Objective-C. Non dovresti usare eccezioni per controlli generali del flusso, o semplicemente per significare errori. Invece dovresti usare i valori di ritorno di un metodo o di una funzione per indicare che è occorso un errore, e fornire informazioni riguardo il problema in un oggetto errore.&lt;br /&gt;
&lt;br /&gt;
In un blocco @catch(), puoi re-lanciare l&#39;eccezione catturata usando la direttiva @throw senza un argomento. Questo può aiutare a rendere il codice più leggibile.&lt;br /&gt;
&lt;br /&gt;
Non sei limitato a lanciare oggetti NSException. Puoi lanciare qualsiasi oggetto Objective-C come un oggetto eccezione. La classe NSException fornisce i metodi che aiutano l&#39;elaborazione dell&#39;eccezione, ma puoi implementare la tua propria classe se vuoi. Puoi anche creare una sottoclasse di NSEdception per implementare tipi di eccezioni, come le eccezioni di file system o eccezioni di comunicazione. &lt;/div&gt;&lt;hr /&gt;&lt;h2&gt;Fine Parte 12&lt;/h2&gt;&lt;div&gt;Finisce qui il dodicesimo articolo di questa Guida dedicato alla gestione delle eccezioni nel linguaggio di programmazione Objective-C. Il prossimo post di questa guida, parlerà brevemente del Threading.&amp;nbsp;  &lt;br /&gt;
&lt;br /&gt;
Segnalatemi eventuali errori, e commentate l&#39;articolo se l&#39;avete trovato utile, anche per incentivarmi a continuare a pubblicare le mie traduzioni. Iscrivetevi ai feed del blog per essere sempre aggiornati automaticamente ogni volta che sono disponibili nuovi contenuti. Nella barra laterale del blog potete trovare l&#39;elenco di tutti gli articoli di questa guida. &lt;/div&gt;&lt;/span&gt; &lt;!-- &lt;/edindex&gt; --&gt; &lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/05/guida-objective-c-in-italiano-le.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-4746006189463468984</guid><pubDate>Mon, 03 May 2010 10:20:00 +0000</pubDate><atom:updated>2010-05-03T12:20:37.459+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">selettori</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - Selettori - Parte 11</title><description>&lt;!-- &lt;EdIndex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align:justify;&quot;&gt;Oggi parleremo dei Selettori del linguaggio Objective-C; vi ricordo che questa è l&#39;undicesima parte della Guida in Italiano alla programmazione in Objective-C, e che nella barra laterale del sito potrete trovare tutti i links agli articoli di questa guida.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2&quot; title=&quot;Guida Originale in Inglese&quot;&gt;questo link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questo articolo può interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;br /&gt;
&lt;/div&gt;&lt;hr&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;h2&gt;Selettori&lt;/h2&gt;&lt;div&gt;In Objective-C, la parola selettore ha due significati. Può essere usata per riferirsi semplicemente al nome di un metodo quando è usato in un messaggio ad un oggetto nel codice sorgente. Si può anche riferire all&#39;identificatore univoco che rimpiazza il nome quando il codice sorgente è compilato. i selettori compilati sono di tipo SEL. Tutti i metodi con lo stesso nome hanno lo stesso selettore. Puoi usare un selettore per invocare un metodo su un oggetto - questo fornisce le basi per l&#39;implementazione del pattern di progettazione target-azione in Cocoa. &lt;/div&gt;&lt;h2&gt;Metodi e Selettori&lt;/h2&gt;&lt;div&gt;Per efficienza, i nomi full ASCII non sono usati come selettori di metodo nel codice compilato. Invece, il compilatore scrive ogni nome di metodo in una tabella e poi accoppia il nome con un identificatore univoco che rappresenta il metodo a runtime. Il sistema di runtime si assicura che ogni identificatore sia univoco: non ci sono due selettori che sono uguali, e tutti i metodi con lo stesso nome hanno lo stesso selettore.&lt;/div&gt;&lt;h2&gt;SEL e @selector&lt;/h2&gt;&lt;div&gt;I selettori compilati sono assegnati a un tipo speciale, SEL, per distinguerli dagli altri dati. I selettori validi non sono mai 0. Devi permettere al sistema di assegnare identificatori SEL ai metodi; è futile assegnarli arbitrariamente.&lt;br /&gt;
&lt;br /&gt;
La direttiva @selector() ti permette di riferirti ai selettori compilati, piuttosto che al completo nome del metodo. Qui, il selettore per setWidth:height: è assegnato alla variabile setWidthHeight:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;SEL setWidthHeight;&lt;br /&gt;
&lt;br /&gt;
setWidthHeight = @selector(setWidth:height:);&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;è più efficiente assegnare valori a variabili SEL a tempo di compilazione con la direttiva @selector(). Comunque, in alcuni casi, potresti aver bisogno di convertire una stringa di caratteri ad un selettore a runtime. Puoi farlo con la funzione NSSelectorFromString:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;setWidthHeight = NSSelectorFromString(aBuffer);&lt;/div&gt;&lt;div&gt;Le conversioni sono possibili anche nella direzione opposta. La funzione NSStringFromSelector restituisce un nome di metodo per un selettore:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;NSString *method;&lt;br /&gt;
&lt;br /&gt;
method = NSStringFromSelector(setWidthHeight);&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Metodi e Selettori&lt;/h2&gt;&lt;div&gt;Selettori compilati identificano nomi di metodi, non implementazioni di metodi. Il metodo display per una classe, ad esempio, ha lo stesso selettore di un metodo display definito nelle altre classi. Questo è essenziale per il polimorfismo e il collegamento dinamico; permette di inviare lo stesso messaggio a riceventi appartenenti a classi diverse. Se ci fosse un selettore per ogni implementazione di metodo, un messaggio non sarebbe differente da una chiamata di funzione.&lt;br /&gt;
&lt;br /&gt;
Un metodo di classe e un metodo di istanza con lo stesso nome sono assegnati allo stesso selettore. Comunque, a causa dei loro domini separati, non c&#39;è confusione tra i due. Una classe potrebbe definire un metodo di classe display in aggiunta al metodo d&#39;istanza display.&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Valori di Ritorno e Tipi di Argomenti dei Metodi&lt;/h2&gt;&lt;div&gt;La routine di messaggistica ha accesso alle implementazioni dei metodi solo attraverso i selettori, quindi li tratta allo stesso modo tutti i metodi con lo stesso selettore. Scopre i tipi restituiti di un metodo, e i tipi di dati dei suoi argomenti, dal selettore. Quindi, eccetto per messaggi inviati a riceventi tipati staticamente, il collegamento dinamico richiede che tutte le implementazioni  dei metodi con lo stesso nome debbano avere lo stesso valore di ritorno e tipi di argomenti. (riceventi staticamente tipati sono un eccezione a questa regola, dato che il compilatore può imparare l&#39;implementazione del metodo dal tipo della classe). &lt;br /&gt;
&lt;br /&gt;
Sebbene i metodi di classe con lo stesso nome e i metodi di istanze siano rappresentati dallo stesso selettore, possono avere argomenti diversi e tipi di ritorno diversi.&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Variare il Messaggio a Runtime&lt;/h2&gt;&lt;div&gt;I metodi performSelector:, performSelector:withObject:, e performSelector:withObject:withObject:, definiti nel protocollo NSObject, prendono gli identificatori SEL come loro argomenti iniziali. Tutti e tre i metodi mappano direttamente nella funzione di messaggistica. Per esempio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;[friend performSelector:@selector(gossipAbout:)&lt;br /&gt;
&lt;br /&gt;
withObject:aNeighbor];&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;è equivalente a:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;[friend gossipAbout:aNeighbor];&lt;/div&gt;&lt;div&gt;Questi metodi rendono possibile variare un messaggio a runtime, come è possibile variare l&#39;oggetto che riceve il messaggio. I nomi di variabili possono essere usati in entrambe le metà di un&#39;espressione di un messaggio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;id   helper = getTheReceiver();&lt;br /&gt;
&lt;br /&gt;
SEL  request = getTheSelector();&lt;br /&gt;
&lt;br /&gt;
[helper performSelector:request];&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;In questo esempio, il ricevente (helper) è scelto a runtime ( dalla funzione fittizia getTheReceiver), e il metodo che il ricevente è chiesto di eseguire (request) è anch&#39;esso determinato a runtime (dalla funzione ugualmente fittizia getTheSelector).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Nota:&lt;/b&gt; performSelector: e i suoi metodi compagni restituiscono un id. Se il metodo che è eseguito restituisce un tipo diverso, dovrebbe essere fatto un cast al tipo appropriato. (comunque, fare il cast non funziona per tutti i tipi; il metodo dovrebbe restituire un puntatore o un tipo compatibile con un puntatore).&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Il Design Pattern Target-Azione &lt;/h2&gt;&lt;div&gt;Nel suo trattamento di controlli di interfacce utente, l&#39;Application Kit fa buon uso dell&#39;abilità di variare sia ricevente che messaggio.&lt;br /&gt;
&lt;br /&gt;
Oggetti NSControl sono graficamente dispositivi che possono essere usati per dare istruzioni ad un&#39;applicazione. La maggior parte somigliano a dispositivi di controllo del mondo reale come bottoni, interruttori, campi di testo, menu ecc... Nel software questi dispositivi si trovano tra applicazione e utente. Essi interpretano gli eventi che vengono dai dispositivi hardware come la tastiera ed il mouse e li traducono in istruzioni specifiche per l&#39;applicazione. Per esempio, un pulsante etichettato &quot;Find&quot; tradurrebbe un click del mouse in un&#39;istruzione per l&#39;applicazione per iniziare a cercare qualcosa.&lt;br /&gt;
&lt;br /&gt;
L&#39;Application Kit definisce un modello per creare dispositivi di controllo e di suo, definisce pochi dispositivi immediatamente disponibili. Ad esempio, la classe NSButtonCell definisce un oggetto che puoi assegnare ad un&#39;istanza di NSMatrix ed inizializzare con una taglia, un&#39;etichetta, un&#39;immagine, un carattere, e una tastiera alternativa. Quando l&#39;utente clicca sul pulsante (o usa la tastiera alternativa), l&#39;oggetto NSButtonCell invia un messaggio che istruisce l&#39;applicazione a fare qualcosa. Per fare questo, un oggetto NSButtonCell deve essere inizializzato non solo con un&#39;immagine, dimensione ed etichetta ma con direzioni su che messaggio inviare e a chi inviarlo. Di conseguenza un&#39;istanza di NSButtonCell può essere inizializzata  per un messaggio d&#39;azione, il selettore del metodo che dovrebbe usare nel messaggio che invia, ed il target, l&#39;oggetto che dovrebbe ricevere il messaggio. &lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;[myButtonCell setAction:@selector(reapTheWind:)];&lt;br /&gt;
&lt;br /&gt;
[myButtonCell setTarget:anObject];&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Il pulsante cella invia il messaggio usando il metodo performSelector:withObject: di NSObject. Tutti i messaggi d&#39;azione prendono un singolo argomento, l&#39;id del dispositivo di controllo che invia il messaggio.&lt;br /&gt;
&lt;br /&gt;
Se Objective-C non permettesse ai messaggi di essere variati, tutti gli oggetti NSButtonCell dovrebbero inviare lo stesso messaggio; il nome del metodo dovrebbe essere congelato nel codice sorgente di NSButtonCell. Invece di implementare semplicemente un meccanismo per traslare le azioni dell&#39;utente in messaggi d&#39;azione, i pulsanti celle e altri controlli dovrebbero vincolare il contenuto del messaggio. Questo renderebbe difficile per qualunque oggetto rispondere a più di un button cell. Ci dovrebbe anche essere un unico target per un pulsante, o l&#39;oggetto target dovrebbe scoprire da quale bottone viene il messaggio e agire di conseguenza.&lt;br /&gt;
&lt;br /&gt;
Ogni volta che riorganizzi l&#39;interfaccia utente, dovresti anche re-implementare il metodo che risponde al messaggio azione. Questa sarebbe una complicazione non necessaria che l&#39;Objective-C evita felicemente.&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Evitare Errori nei Messaggi&lt;/h2&gt;&lt;div&gt;Se un oggetto riceve un messaggio per eseguire un metodo che non è nel suo repertorio, risulterà un errore. è la stessa sorta di errore di chiamare una funzione non esistente. Ma poiché i messaggi occorrono a runtime, l&#39;errore spesso non è evidente finché il programma non viene eseguito.&lt;br /&gt;
&lt;br /&gt;
è relativamente semplice evitare questi errori quando il selettore del messaggio è costante e la classe dell&#39;oggetto ricevente è conosciuta. Come scrivi i tuoi programmi, puoi accertarti che il ricevente sia in grado di rispondere. Se il ricevente è tipato staticamente, il compilatore esegue questo test per te.&lt;br /&gt;
&lt;br /&gt;
Comunque, se il selettore dl messaggio o la classe del ricevente varia, potrebbe essere necessario post-porre questo test fino a runtime. Il metodo respondsToSelector:, definito nella classe NSObject, determina se un ricevente può rispondere ad un messaggio. Prende il selettore di metodo come un argomento e restituisce se il ricevente ha accesso a metodi che combaciano con il selettore:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;if ( [anObject respondsToSelector:@selector(setOrigin::)] )&lt;br /&gt;
&lt;br /&gt;
[anObject setOrigin:0.0 :0.0];&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
&lt;br /&gt;
fprintf(stderr, &quot;%s can’t be placed\n&quot;,&lt;br /&gt;
&lt;br /&gt;
[NSStringFromClass([anObject class]) UTF8String]);&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Il test respondsToSelector: è specialmente importante quando si inviano messaggi ad oggetti di cui non hai il controllo al tempo di compilazione. Ad esempio, se scrivi codice che invia un messaggio ad un oggetto rappresentato da una variabile che altri possono impostare, dovresti accertarti che il ricevente implementi un metodo che risponda al messaggio.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Nota:&lt;/b&gt; Un oggetto si può anche sistemare per avere i messaggi che riceve, inoltrati ad altri oggetti se esso non può rispondere direttamente ai messaggi da solo. In tal caso, appare che l&#39;oggetto può gestire il messaggio, anche se l&#39;oggetto risponde al messaggio indirettamente assegnandolo ad un altro oggetto. &lt;br /&gt;
&lt;/div&gt;&lt;hr&gt;&lt;h2&gt;Fine Parte 11&lt;/h2&gt;&lt;div&gt;Finisce qui l&#39;undicesimo articolo di questa Guida dedicato ai Selettori del linguaggio di programmazione Objective-C. Il prossimo post di questa guida, parlerà della Gestione delle Eccezioni.&lt;br /&gt;
&lt;br /&gt;
Segnalatemi eventuali errori, o commentate l&#39;articolo se l&#39;avete trovato utile, anche per incentivarmi a continuare a pubblicare le mie traduzioni. Iscrivetevi ai feed del blog per essere sempre aggiornati automaticamente ogni volta che sono disponibili nuovi contenuti.&lt;br /&gt;
Nella barra laterale del blog potete trovare l&#39;elenco di tutti gli articoli di questa guida.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;/span&gt; &lt;!-- &lt;/EdIndex&gt; --&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/05/guida-objective-c-in-italiano-selettori.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-8293193219930594928</guid><pubDate>Sun, 02 May 2010 14:03:00 +0000</pubDate><atom:updated>2010-05-02T16:03:15.805+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">comportamenti statici</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">tipatura statica</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - Comportamenti Statici - Parte 10</title><description>&lt;!-- &lt;EdIndex&gt; --&gt; &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Nel decimo capitolo della Guida in Italiano alla programmazione in Objective-C, parleremo approfonditamente della tipatura statica, abilitare comportamenti statici rispetto a quelli che in Objective-C sono dinamici di default.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2&quot; title=&quot;Guida Originale in Inglese&quot;&gt;questo link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questo articolo può interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;/div&gt;&lt;hr /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;h2&gt;Abilitare Comportamenti Statici&lt;/h2&gt;&lt;div&gt;Questo capitolo spiega come funziona la tipatura statica e parla di alcune altre caratteristiche dell&#39;Objective-C, incluso metodi per sovrastare temporaneamente il suo dinamismo inerente.&lt;/div&gt;&lt;h2&gt;Comportamento Dinamico di Default&lt;/h2&gt;&lt;div&gt;Da progettazione, gli oggetti Objective-C sono entità dinamiche. Quante più decisioni possibili su di loro sono spinte dal tempo di compilazione al tempo di esecuzione:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;La memoria per gli oggetti è allocata dinamicamente a runtime dai metodi di classe che creano nuove istanze.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Gli Oggetti sono tipati dinamicamente. Nel codice sorgente (a tempo di compilazione), ogni variabile di un oggetto può essere tipata id, non importa di che classe sia l&#39;oggetto. L&#39;esatta classe di una variabile id (e quindi i suoi metodi particolari e la struttura dati) non è determinata finché il programma non è in esecuzione.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Messaggi e metodi sono legati dinamicamente. Una procedura di runtime fà combaciare il selettore di metodo nel messaggio con un&#39;implementazione di metodo che appartiene al ricevente.&lt;/li&gt;
&lt;/ul&gt;Queste caratteristiche danno ai programmi OO una grande flessibilità, ma c&#39;è un prezzo da pagare. In particolare, il compilatore non può controllare i tipi esatti (classi) delle variabili id. Per permettere un miglior controllo di tipo a tempo di compilazione, e per rendere il codice più auto-documentante, Objective-C permette agli oggetti di essere tipati staticamente con un nome di classe piuttosto che la tipatura generica come id. Permette anche di spegnere  alcune delle caratteristiche OO per spostare operazioni dal tempo di esecuzione a quello di compilazione.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Nota:&lt;/b&gt; I messaggi sono qualcosa di più lento delle chiamate a funzioni, tipicamente incorrono in una quantità insignificante di lavoro aggiuntivo comparati al lavoro attualmente eseguito. Il caso particolarmente raro in cui bypassare il dinamismo dell&#39;Objective-C potrebbe essere permesso, può essere provato usando gli strumenti di analisi come Shark o Instruments. &lt;/div&gt;&lt;h2&gt;Tipatura Statica&lt;/h2&gt;&lt;div&gt;Se un puntatore ad un nome di classe è usato al posto di un id in una dichiarazione di oggetto,&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Rectangle *thisObject;&lt;/div&gt;&lt;div&gt;Il compilatore restringe il valore della variabile dichiarata ad essere o un&#39;istanza della classe nominata nella dichiarazione o un&#39;istanza di una classe che eredita dalla classe nominata. Nell&#39;esempio sopra, ThisObject può essere solo un Rectangle di un qualche tipo.&lt;br /&gt;
&lt;br /&gt;
Tipare staticamente oggetti ha la stesse strutture dati interne degli oggetti dichiarati id. Il tipo non influenza l&#39;oggetto; influenza dolo la quantità di informazione data al compilatore circa l&#39;oggetto e la quantità di informazione disponibile a quelli che leggono il codice sorgente.&lt;br /&gt;
&lt;br /&gt;
La tipatura statica non influenza neanche il modo in cui l&#39;oggetto è trattato a runtime. Gli oggetti staticamente tipati sono allocati dinamicamente dagli stessi metodi di classe che creano le istanze di tipo id. Se Square (quadrato) è una sottoclasse di Rectangle, il seguente codice produrrà ancora un oggetto con tutte le variabili di istanza di uno Square, non solo quelle di un Rectangle:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Rectangle *thisObject = [[Square alloc] init];&lt;/div&gt;&lt;div&gt;I messaggi inviati ad oggetti tipati staticamente sono legati dinamicamente, proprio come per gli oggetti tipati id. Il tipo esatto di un ricevente tipato staticamente è determinato ancora a runtime come una parte del processo di messaggistica. Un messaggio display inviato a thisObject&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;[thisObject display];&lt;/div&gt;&lt;div&gt;esegue la versione del metodo definita nella classe Square, non in quella della sua superclasse Rectangle.&lt;br /&gt;
&lt;br /&gt;
Dando al compilatore più informazioni su un oggetto, la tipatura statica apre le possibilità che siano queste info siano assenti per oggetti tipati id:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;In alcune situazioni, permette i controlli di tipo a tempo di compilazione.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Può liberare oggetti dalla restrizione che i metodi nominati identicamente devono avere identici valori di ritorno e tipi di argomenti.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Permette di usare la struttura operatore punto per accedere direttamente alle variabili d&#39;istanza di un oggetto.&lt;/li&gt;
&lt;/ul&gt;I primi due argomenti sono discussi nella sezione che segue. Il terzo è spiegato nel secondo articolo di questa guida &quot;Definire Classi&quot;. &lt;/div&gt;&lt;h2&gt;Controlli di Tipo&lt;/h2&gt;&lt;div&gt;Con l&#39;informazione aggiuntiva fornita dalla tipatura statica, il compilatore può consegnare un servizio di controllo di tipi migliore in due situazioni:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Quando un messaggio è inviato a un ricevente tipato staticamente, il compilatore può assicurarsi che il ricevente può rispondere. Un warning è emesso se il ricevente non ha accesso al metodo nominato nel messaggio.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Quando un oggetto tipato staticaemente  è assegnato a una variabile tipata staticamente, il compilatore si accerta che i tipi siano compatibili. Emette un warning se non lo sono.&lt;/li&gt;
&lt;/ol&gt;Un assegnamento può essere fatto senza warning, se la classe dell&#39;oggetto definito è identica a, o eredita da, la classe della variabile che riceve l&#39;assegnamento. Il seguente esempio illustra questo: &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Shape     *aShape;&lt;br /&gt;
&lt;br /&gt;
Rectangle *aRect;&lt;br /&gt;
&lt;br /&gt;
aRect = [[Rectangle alloc] init];&lt;br /&gt;
&lt;br /&gt;
aShape = aRect;  &lt;/div&gt;&lt;div&gt;Qui aRect può essere assegnato a aShape perchè un Rectangle è un tipo di Shape - la classe Rectangle eredita da Shape. Comunque, se i ruoli delle due variabili sono invertiti e aShape è assegnata a aRect, il compilatore genera un warning; non tutte le forme sono Rettangoli.&lt;br /&gt;
&lt;br /&gt;
Non c&#39;è controllo quando l&#39;espressione su uno dei due lati dell&#39;assegnamento è un id. Un oggetto tipato staticamente può essere liberamente assegnato ad un id, o un id a un oggetto tipato staticamente. Perché i metodi come alloc ed init restituiscono variabili tipate staticamente. Il seguente codice è incline ad errori, ma ciò nonostante si concede:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Rectangle *aRect;&lt;br /&gt;
&lt;br /&gt;
aRect = [[Shape alloc] init];   &lt;/div&gt;&lt;h2&gt;Tipi di Ritorno e degli Argomenti &lt;/h2&gt;&lt;div&gt;In generale, i metodi in classi diverse che hanno lo stesso selettore (lo stesso nome) devono anche condividere gli stessi tipi di ritorno e tipi di argomenti. Questo vincolo è imposto dal compilatore per permettere il collegamento dinamico (dynamic binding). Poiché la classe di un messaggio ricevente, (e quindi dettagli specifici di classe riguardo al metodo che gli è chiesto di eseguire) non può essere conosciuta a tempo di compilazione, il compilatore deve trattare allo stesso modo tutti i metodi con lo stesso nome. Quando prepara le informazioni sul ritorno del metodo e sui tipi degli argomenti per il sistema di runtime, crea solo una descrizione di metodo per ogni selettore di metodo.&lt;br /&gt;
&lt;br /&gt;
Comunque, quando un messaggio è inviato a un oggetto tipato staticamente, la classe del ricevente è conosciuta dal compilatore. Il compilatore ha accesso a informazioni specifiche della classe riguardo ai metodi. Quindi, il messaggio è liberato dalle restrizioni sui suoi valori di ritorno e tipi di argomenti.  &lt;/div&gt;&lt;h2&gt;Tipatura Statica a una Classe Ereditata &lt;/h2&gt;&lt;div&gt;Un&#39;istanza può essere tipata staticamente alla sua propria classe o a qualunque classe da cui eredita. Tutte le istanze, ad esempio, possono essere tipate staticamente come NSObject.&lt;br /&gt;
&lt;br /&gt;
Comunque, il compilatore capisce la classe di un oggetto tipato staticamente solo dal nome di classe nella designazione del tipo, ed effettua il suo controllo di tipi di conseguenza. Tipare un&#39;istanza a una classe ereditata può quindi risultare in discrepanze tra ciò che il compilatore pensa che potrebbe accadere a runtime e cosa realmente succede.&lt;br /&gt;
&lt;br /&gt;
Ad esempio, se tipi staticamente un&#39;istanza di Rectangle come una Shape,  &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Shape *myRectangle = [[Rectangle alloc] init]; &lt;/div&gt;&lt;div&gt;Il compilatore la tratterà come una Shape. Se invii all&#39;oggetto un messaggio per eseguire un metodo di Rectangle, &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;BOOL solid = [myRectangle isFilled]; &lt;/div&gt;&lt;div&gt;Il compilatore si lamenterà. Il metodo isFilled è definito nella classe Rectangle ma non in Shape.&lt;br /&gt;
&lt;br /&gt;
Comunque, se gli invii un messaggio per eseguire un metodo che classe Shape conosce, &lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;[myRectangle display]; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Il compilatore non si lamenterà, anche se Rectangle sovrascrive il metodo. A runtime, è eseguita la versione del metodo di Rectangle.&lt;br /&gt;
&lt;br /&gt;
In modo analogo, supponiamo che la classe sorastante dichiara un metodo worry che restituisce un double, &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (double)worry; &lt;/div&gt;&lt;div&gt;e la sottoclasse di mezzo sovrascrive il metodo e dichiara un nuovo tipo di ritorno: &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (int)worry; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Se un&#39;istanza è tipata staticamente alla classe superiore, il compilatore penserà che il suo metodo worry restituisce un double, e se un istanza è tipata alla classe di mezzo, penserà che worry restituisce un intero. Risulteranno ovviamente errori se un&#39;istanza della classe di mezzo è tipata alla classe superiore. Il compilatore informerà il sistema di runtime che un messaggio worry è inviato ad un oggetto che restituisce un double, ma a runtime esso restituisce attualmente un int e genera un errore.&lt;br /&gt;
&lt;br /&gt;
La tipatura statica può liberare metodi nominati in modo identico dalla restrizione che devono avere valori di ritorno e tipi di argomento identici, ma lo può fare così affidabilmente solo se i metodi sono dichiarati in rami differenti della gerarchia delle classi. &lt;/div&gt;&lt;hr /&gt;&lt;h2&gt;Fine Parte 10&lt;/h2&gt;&lt;div&gt;Finisce qui il decimo articolo di questa Guida dedicato alla tipatura statica nel linguaggio di programmazione Objective-C.  Il prossimo post di questa guida, parlerà dei Selettori.&lt;br /&gt;
&lt;br /&gt;
Segnalatemi eventuali errori, o commentate l&#39;articolo se l&#39;avete trovato utile, anche per incentivarmi a continuare a pubblicare le mie traduzioni. Iscrivetevi ai feed del blog per essere sempre aggiornati automaticamente ogni volta che sono disponibili nuovi contenuti. Nella barra laterale del blog potete trovare l&#39;elenco di tutti gli articoli di questa guida. &lt;/div&gt;&lt;/span&gt; &lt;!-- &lt;/EdIndex&gt; --&gt; &lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/05/guida-objective-c-in-italiano.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-7940060665291466020</guid><pubDate>Sat, 01 May 2010 10:25:00 +0000</pubDate><atom:updated>2010-05-01T12:26:07.689+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">enumerazione veloce</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - Parte 9 - Enumerazione Veloce</title><description>&lt;!-- &lt;EdIndex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Enumerare oggetti di una collezione, tramite la caratteristica Enumerazione Veloce; questo sarà l&#39;argomento trattato oggi, in questa nona parte della Guida in Italiano alla programmazione in Objective-C.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2&quot; title=&quot;Guida Originale in Inglese&quot;&gt;questo link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questo articolo può interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;/div&gt;&lt;hr /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;h2&gt;Enumerazione Veloce&lt;/h2&gt;&lt;div&gt;L&#39;enumerazione veloce è una caratteristica del linguaggio che ti permette di enumerare in modo sicuro ed efficiente i contenuti di una collezione usando una sintassi efficiente.&lt;/div&gt;&lt;h2&gt;La caratteristica for…in&lt;/h2&gt;&lt;div&gt;L&#39;enumerazione veloce è una caratteristica del linguaggio che ti permette di enumerare in modo sicuro ed efficiente i contenuti di una collezione usando una sintassi efficiente. La sintassi è definita come segue:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;for ( Tipo nuovaVariabile in espressione ) { statements }&lt;/div&gt;&lt;div&gt;o&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Tipo nuovaVariabile;&lt;br /&gt;
&lt;br /&gt;
for ( nuovaVariabile in expression ) { statements }&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;In entrambi i casi, le espressioni raccolgono un oggetto conforme al protocollo NSFastEnumeration. La variabile che itera è impostata a turno ad ogni elemento nell&#39;oggetto restituito, e il codice definito dagli statements è eseguito. La variabile che itera è impostata a nil quando il ciclo finisce esaurendo la sorgente del gruppo di oggetti. Se il ciclo è terminato presto, la variabile che itera è lasciata a puntare all&#39;ultimo elemento dell&#39;iterazione.&lt;br /&gt;
&lt;br /&gt;
Ci sono molti vantaggi dell&#39;uso dell&#39;enumerazione veloce:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;L&#39;enumerazione è considerevolmente più efficiente rispetto ad usare direttamente NSEnumerator.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;La sintassi è concisa.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;L&#39;enumerazione è sicura - l&#39;enumeratore ha una sentinella di mutazione, così che provi a modificare la collezione durante l&#39;enumerazione, verrà emessa un&#39;eccezione.&lt;/li&gt;
&lt;/ul&gt;Dato che la mutazione dell&#39;oggetto durante l&#39;iterazione è vietata, puoi eseguire anche enumerazioni multiple contemporaneamente. &lt;/div&gt;&lt;h2&gt;Adottare l&#39;enumerazione veloce&lt;/h2&gt;&lt;div&gt;Qualsiasi classe le cui istanze forniscono un accesso ad una collezione di altri oggetti può adottare il protocollo NSFastEnumeration. La collezione di classi Cocoa - NSArray, NSDictionary, e NSSet - adottano questo protocollo, come fà NSEnumerator. Dovrebbe essere ovvio che nei casi di NSArray e NSSet l&#39;enumerazione riguarda i loro contenuti. Per altre classi, la documentazione corrispondente potrebbe chiarire che proprietà è iterata - ad esempio, NSDictionary e la classe NSManageObjectModel del Core Data forniscono supporto per l&#39;enumerazione veloce; NSDictionary numera le sue chiavi, e NSManageObjectModel enumera le sue entità.&lt;/div&gt;&lt;h2&gt;Usare l&#39;enumerazione veloce&lt;/h2&gt;&lt;div&gt;Il seguente codice d&#39;esempio illustra l&#39;uso dell&#39;enumerazione veloce con oggetti NSArray e NSDictionary.&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;NSArray *array = [NSArray arrayWithObjects:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; @&quot;One&quot;, @&quot;Two&quot;, @&quot;Three&quot;, @&quot;Four&quot;, nil];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;for (NSString *element in array) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; NSLog(@&quot;element: %@&quot;, element);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; @&quot;quattuor&quot;, @&quot;four&quot;, @&quot;quinque&quot;, @&quot;five&quot;, @&quot;sex&quot;, @&quot;six&quot;, nil];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;NSString *key;&lt;br /&gt;
&amp;nbsp;for (key in dictionary) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;NSLog(@&quot;English: %@, Latin: %@&quot;, key, [dictionary valueForKey:key]);&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Puoi anche usare oggetti NSEnumerator con l&#39;enumerazione veloce, come illustrato nel seguente esempio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;NSArray *array = [NSArray arrayWithObjects:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; @&quot;One&quot;, @&quot;Two&quot;, @&quot;Three&quot;, @&quot;Four&quot;, nil];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;NSEnumerator *enumerator = [array reverseObjectEnumerator];&lt;br /&gt;
&amp;nbsp;for (NSString *element in enumerator) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;if ([element isEqualToString:@&quot;Three&quot;]) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;NSString *next = [enumerator nextObject];&lt;br /&gt;
&amp;nbsp;// next = &quot;Two&quot;  &lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Per collezioni o enumeratori che hanno un ordine ben definito - come NSArray o istanze di NSEnumerator derivate da un array - l&#39;enumerazione procede in quell&#39;ordine, quindi, per conoscere l&#39;indice dell&#39;elemento della collezione che vi serve, vi basterà contare le iterazioni. &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;NSArray *array = /* assume this exists */;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;NSUInteger index = 0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;for (id element in array) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;NSLog(@&quot;Element at index %u is: %@&quot;, index, element);      index++;&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
In altri rispetti, la caratteristica si comporta come un ciclo for standard. Puoi usare break per interrompere l&#39;iterazione; e se vuoi saltare elementi puoi usare uno statement condizionale annidato come mostrato nel seguente esempio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;NSArray *array = /* assumiamo che questo esista */;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;for (id element in array) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;if (/* qualche test per l&#39;elemento */) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // statements che si applicano ai soli elementi che superano il test&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Se vuoi saltare il primo elemento e poi processare non più di cinque ulteriori elementi, potresti fare come mostrato in questo esempio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;NSArray *array = /* assumiamo che questo esista */;&lt;br /&gt;
NSUInteger index = 0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;for (id element in array) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;if (index != 0) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NSLog(@&quot;Element at index %u is: %@&quot;, index, element);&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;if (++index &amp;gt;= 6) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;&lt;hr /&gt;&lt;h2&gt;Fine Parte 9&lt;/h2&gt;&lt;div&gt;Finisce qui il nono articolo di questa Guida dedicato all&#39;Enumerazione Veloce del linguaggio di programmazione Objective-C.   Il prossimo post di questa guida, parlerà di come abilitare comportamenti statici; vedremo quindi più in dettaglio come funziona la tipatura statica, e discuteremo di alcune caratteristiche dell&#39;Objective-C come vari modi per sormontare temporaneamente il suo dinamismo.&lt;br /&gt;
&lt;br /&gt;
Segnalatemi eventuali errori, o commentate l&#39;articolo se l&#39;avete trovato utile, anche per incentivarmi a continuare a pubblicare le mie traduzioni. Iscrivetevi ai feed del blog per essere sempre aggiornati automaticamente ogni volta che sono disponibili nuovi contenuti.&lt;br /&gt;
Nella barra laterale del blog potete trovare l&#39;elenco di tutti gli articoli di questa guida.&lt;/div&gt;&lt;/span&gt; &lt;!-- &lt;/EdIndex&gt; --&gt; &lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/05/guida-objective-c-in-italiano-parte-9.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-1174803743758652593</guid><pubDate>Fri, 30 Apr 2010 09:21:00 +0000</pubDate><atom:updated>2010-05-01T12:51:06.366+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">riferimenti associativi</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - Parte 8 - Riferimenti Associativi</title><description>&lt;!-- &lt;EdIndex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Questa è l&#39;ottava parte della Guida alla programmazione in Objective-C, oggi parleremo di Riferimenti Associativi.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2&quot; title=&quot;Guida Originale in Inglese&quot;&gt;questo link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questo articolo può interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;/div&gt;&lt;hr /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;h2&gt;Riferimenti Associativi&lt;/h2&gt;&lt;div&gt;Si usano i riferimenti associativi per simulare l&#39;aggiunta di variabili di istanza di un oggetto ad una classe esistente.&lt;br /&gt;
&lt;br /&gt;
I riferimenti associativi sono disponibili solo in Mac OS X v10.6 e successivi.&lt;/div&gt;&lt;h2&gt;Aggiungere Memoria fuori a una Definizione di Classe&lt;/h2&gt;&lt;div&gt;Usando i riferimenti associativi, puoi aggiungere memoria ad un oggetto senza modificare la dichiarazione di classe. Questo può essere utile se non hai accesso al codice sorgente della classe, o se per motivi di compatibilità binaria non puoi alterare il layout dell&#39;oggetto.&lt;br /&gt;
&lt;br /&gt;
Le Associazioni sono basate su una chiave, quindi per ogni oggetto puoi aggiungere quante associazioni vuoi, ognuna usando una chiave diversa. Un&#39;associazione può anche assicurare che l&#39;oggetto associato rimane valido per almeno il tempo di vita dell&#39;oggetto sorgente (senza la possibilità di introdurre cicli non riscuotibili in un ambiente garbage-collected).&lt;/div&gt;&lt;h2&gt;Creare Associazioni&lt;/h2&gt;&lt;div&gt;Usate la funzione Objective-C di runtime objc_setAssociatedObject per creare un&#39;associazione tra un oggetto ed un altro. La funzione prende quattro argomenti: l&#39;oggetto sorgente, una chiave, il valore e una politica di associazione costante. Di queste, la chiave e la politica di associazione meritano ulteriori discussioni.&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;La chiave è un puntatore a void. La chiave per ogni associazione deve essere unica. Un pattern tipico è usare una variabile statica.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;La politica specifica se l&#39;oggetto associato è assegnato, conservato o copiato (assign, retain, copy) e se l&#39;associazione è fatta atomicamente o non-atomicamente. Questo segue un pattern simile agli attributi di una proprietà dichiarata. Specifica la politica per la relazione usando una costante (vedi objc_AssociationPolicy).&lt;/li&gt;
&lt;/ul&gt;Il seguente esempio mostra come puoi stabilire un&#39;associazione tra un array ed una stringa.&lt;br /&gt;
&lt;b&gt;Listato 7-1&lt;/b&gt;  Stabilire un&#39;associazione tra un array e una stringa &lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codice&quot;&gt;static char overviewKey;  &lt;br /&gt;
&lt;br /&gt;
NSArray *array = [[NSArray alloc] initWithObjects:@&quot;One&quot;, @&quot;Two&quot;, @&quot;Three&quot;, nil];  &lt;br /&gt;
&lt;br /&gt;
// For the purposes of illustration, use initWithFormat: to ensure the string can be deallocated  &lt;br /&gt;
&lt;br /&gt;
NSString *overview = [[NSString alloc] initWithFormat:@&quot;%@&quot;, @&quot;First three numbers&quot;];  &lt;br /&gt;
&lt;br /&gt;
objc_setAssociatedObject(array, &amp;amp;overviewKey, overview, OBJC_ASSOCIATION_RETAIN);  &lt;br /&gt;
&lt;br /&gt;
[overview release];  &lt;br /&gt;
&lt;br /&gt;
// (1) overview valid  &lt;br /&gt;
&lt;br /&gt;
[array release];  &lt;br /&gt;
&lt;br /&gt;
// (2) overview invalid  &lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Al punto (1), la stringa overview è ancora valida poiché la politica OBJC_ASSOCIATION_RETAIN specifica che l&#39;array conserva l&#39;oggetto associato. Quando l&#39;array è deallocato, (al punto 2), overview è rilasciata e in questo caso quindi, anche deallocata. Se provi, ad esempio, ad annotare  il valore di overview, genererai un&#39;eccezione di runtime.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;Recuperare Oggetti Associati&lt;/h2&gt;&lt;div&gt;Puoi recuperare un oggetto associato usando la funzione di runtime di Objective-C objc_getAssociatedObject. Continuando l&#39;esempio mostrato nel listato 7-1, puoi recuperare overview dall&#39;array usando la seguente linea di codice:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;NSString *associatedObject = (NSString *)objc_getAssociatedObject(array, &amp;amp;overviewKey);&lt;/div&gt;&lt;h2&gt;Rompere Associazioni&lt;/h2&gt;&lt;div&gt;Per rompere un&#39;associazione, si usa tipicamente objc_setAssociatedObject, passandogli nil come valore.  Continuando l&#39;esempio mostrato nel listato 7-1, potresti rompere l&#39;associazione tra array e stringa overview usando la seguente linea di codice: &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;objc_setAssociatedObject(array, &amp;amp;overviewKey, nil, OBJC_ASSOCIATION_ASSIGN);&lt;/div&gt;&lt;div&gt;(Dato che l&#39;oggetto associato è stato impostato a nil, la politica non è attualmente importante).  Per rompere tutte le associazioni di un oggetto, puoi usare objc_removeAssociatedObjects. In generale, è sconsigliato usare questo dato che rompe tutte le associazioni per tutti i clienti. Usa questa funzione solo se hai bisogno di restaurare un oggetto a condizioni incontaminate. &lt;/div&gt;&lt;h2&gt;Esempio Completo&lt;/h2&gt;&lt;div&gt;Il seguente programma combina gli esempi di codice delle sezioni precedenti.&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;#import &lt;foundation/foundation.h&gt; &lt;br /&gt;
#import &lt;objc/runtime.h&gt;  &lt;br /&gt;
&lt;br /&gt;
int main (int argc, const char * argv[]) { &lt;br /&gt;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; &lt;br /&gt;
&lt;br /&gt;
static char overviewKey;  &lt;br /&gt;
&lt;br /&gt;
NSArray *array = [[NSArray alloc] initWithObjects:@&quot;One&quot;, @&quot;Two&quot;, @&quot;Three&quot;, nil];&lt;br /&gt;
// For the purposes of illustration, use initWithFormat: to ensure we get a  // deallocatable string &lt;br /&gt;
NSString *overview = [[NSString alloc] initWithFormat:@&quot;%@&quot;, @&quot;First three numbers&quot;];  &lt;br /&gt;
&lt;br /&gt;
objc_setAssociatedObject(array, &amp;amp;overviewKey, overview, OBJC_ASSOCIATION_RETAIN); &lt;br /&gt;
[overview release];    &lt;br /&gt;
&lt;br /&gt;
NSString *associatedObject = (NSString *)objc_getAssociatedObject(array, &amp;amp;overviewKey); &lt;br /&gt;
NSLog(@&quot;associatedObject: %@&quot;, associatedObject); &lt;br /&gt;
&lt;br /&gt;
objc_setAssociatedObject(array, &amp;amp;overviewKey, nil, OBJC_ASSOCIATION_ASSIGN); &lt;br /&gt;
[array release]; &lt;br /&gt;
&lt;br /&gt;
[pool drain]; &lt;br /&gt;
return 0; &lt;br /&gt;
}&lt;br /&gt;
&lt;/objc/runtime.h&gt;&lt;/foundation/foundation.h&gt;&lt;/div&gt;&lt;hr /&gt;&lt;h2&gt;Fine Ottava parte&lt;/h2&gt;&lt;div&gt;Finisce qui l&#39;ottavo articolo di questa Guida dedicato ai Riferimenti Associativi del linguaggio di programmazione Objective-C.    Spero col tempo di realizzare un&#39;utile manuale disponibile a tutti. Il prossimo post di questa guida, tratterà l&#39;Enumerazione Veloce, un utile strumento che fornisce una sintassi concisa, efficiente e sicura, per enumerare i contenuti di una collezione. Segnalatemi eventuali errori, o commentate l&#39;articolo se l&#39;avete trovato utile, anche per incentivarmi a continuare a pubblicare le mie traduzioni. Iscrivetevi ai feed del blog per essere sempre aggiornati automaticamente ogni volta che sono disponibili nuovi contenuti. Nella barra laterale del blog potete trovare l&#39;elenco di tutti gli articoli di questa guida.&lt;/div&gt;&lt;/span&gt;  &lt;!-- &lt;/EdIndex&gt; --&gt;&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/04/guida-objective-c-in-italiano-parte-8.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-2855282921912857366</guid><pubDate>Thu, 29 Apr 2010 12:44:00 +0000</pubDate><atom:updated>2010-04-29T14:44:44.084+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">categorie</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">estensioni</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - Parte 7 - Categorie ed Estensioni</title><description>&lt;!-- &lt;edindex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align:justify;&quot;&gt;Eccoci alla settima parte della Guida alla programmazione in Objective-C, oggi parleremo di Categorie ed Estensioni.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2&quot; title=&quot;Guida Originale in Inglese&quot;&gt;questo link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questo articolo può interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;/div&gt;&lt;hr&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;h2&gt;Categorie ed Estensioni&lt;/h2&gt;&lt;div&gt;Una categoria ti permette di aggiungere metodi ad una classe esitente - anche ad una di cui no hai il codice sorgente. Questa è una caratteristica molto potente che ti permette di estendere le funzionalità di una classe esistente senza crearne una sottoclasse. Usando le categorie, puoi anche dividere l&#39;implementazione delle tue classi tra molti files. Le estensioni delle classi sono simili, ma permettono ad API aggiuntive richieste di essere dichiarate per una classe in locazioni diverse dal blocco @interface della classe primaria.&lt;/div&gt;&lt;h2&gt;Aggiungere Metodi a Classi&lt;/h2&gt;&lt;div&gt;Puoi aggiungere metodi ad una classe dichiarandoli in un file interfaccia sotto un nome di categoria e definendoli in un file implementazione sotto lo stesso nome. Il nome di categoria indica che i metodi sono delle aggiunte ad una classe dichiarata da qualche altra parte, non una nuova classe. non pouoi, comunque usare una categoria per aggiungere variabili di istanza ad una classe.&lt;br /&gt;
&lt;br /&gt;
I metodi che la categoria aggiunge diventano parte del tipo della classe. Ad esempio i metodi aggiunti alla classe NSArray in una categoria sono tra i metodi che il compilatore si aspetta di trovare nel repertorio dei metodi di un&#39;istanza della classe NSArray. I metodi aggiunti alla classe NSArray in una sottoclasse non sono inclusi nel tipo NSArray. (Questo importa solo per oggetti tipati staticamente dato che lo static typing è l&#39;unico modo per il compilatore di conoscere la classe di un oggetto).&lt;br /&gt;
&lt;br /&gt;
I metodi di Categoria possono fare qualunque cosa che possono fare i metodi definiti nella classe. A runtime non c&#39;è differenza. I metodi che la categoria aggiunge alla classe sono ereditati da tutte le sottoclassi, proprio come gli altri metodi.&lt;br /&gt;
&lt;br /&gt;
La dichiarazione di un&#39;interfaccia di categoria appare molto come una dichiarazione di interfaccia di classe - tranne che il nome di categoria è elencato tra parentesi dopo il nome di classe e la superclasse non è menzionata. A meno che i suoi metodi non accedano ad alcuna variabile di istanza della classe, la categoria deve importare il file interfaccia della classe che estende:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;#import &quot;ClassName.h&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@interface ClassName ( CategoryName )&lt;br /&gt;
&lt;br /&gt;
// method declarations&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;L&#39;implementazione, come al solito, importa la sua propria interfaccia. Una convenzione comune per i nomi è che il nome del file di base della categoria è il nome della classe che la categoria estende seguito da un &quot;+&quot; seguito dal nome della categoria. Un&#39;implementazione di categoria (in un file nominato NomeClasse+NomeCategoria.m) potrebbe quindi apparire così:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;#import &quot;ClassName+CategoryName.h&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation ClassName ( CategoryName )&lt;br /&gt;
&lt;br /&gt;
// method definitions&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Nota che una categoria non può dichiarare variabil idi istanza aggiuntive per la classe; include solo metodi. Comnque, tutte le variabili di istanza entro lo scope della classe sono anche nello scope della categoria. questo include tutte le variabili di istanza dichiarate dalla classe, anche quelle dichiarate @private.&lt;br /&gt;
&lt;br /&gt;
Non c&#39;è limite al numero di categorie che puoi aggiungere ad una classe, ma ogni nome di categoria deve essere diverso, ed ognuno dovrebbe dichiarare e definire un insieme diverso di metodi.&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Come Usare le Categorie&lt;/h2&gt;&lt;div&gt;Ci sono tanti modi di usare le categorie:&lt;ul&gt;&lt;li&gt;Per estendere classi definite da altrei implementatori. Ad esempio, se puoi aggiungre metodi alle classi definite nel frameworks Cocoa. I metodi aggiunti sono ereditati dalle sottoclassi e sono indistinguibili a runtime dai metodi originali della classe.&lt;/li&gt;
&lt;li&gt;Come alternativa ad una sottoclasse. Piuttosto che definire una sottoclasse per estendere una classe esistente, attraverso una categoria puoi aggiungeremetodi alla classe direttamente. Ad esempio, puoi aggiungere categorie a NSArray e altre classi Cocoa. Come nel caso di una sottoclasse, non hai bisogno del codice sorgente della classe che stai estendendo.&lt;/li&gt;
&lt;li&gt;Per distribuire l&#39;implementazione di una nuova classe in files sorgenti separati. Ad esempio, puoi raggruppare i metodi di una classe grande in diverse categorie e mettere ogni categoria in un file diverso. Quando sono usate in questo modo, le categorie possono beneficiare del processo di sviluppo in un vari modi - Esse:&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;Forniscono un semplice modo di raggruppare metodi correlati. Metodi simili definiti in classi diverse possono essere messi insieme nello stesso file sorgente.&lt;/li&gt;
&lt;li&gt;Semplifica la gestione di una classe grande quando molti sviluppatori contribuiscono alla sua definizione.&lt;/li&gt;
&lt;li&gt;Ti permette di raggiungere alcuni dei benefici della compilazione incrementale per una classe molto grande.&lt;/li&gt;
&lt;li&gt;Può aiutare a migliorare la località delle referenze per metodi comunemente usati.&lt;/li&gt;
&lt;li&gt;Ti Abilita a configurare una classe diversamente per applicazioni separate, senza dover mantenere diverse versioni dello stesso codice.&lt;/li&gt;
&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;
Sebbene il linguaggio ti permette di usare una categoria per sovrascrivere i metodi che la classe eredita, o anche i metodi dichiarati nell&#39;interfaccia della classe, è fortemente sconsigliato l&#39;uso di questa funzionalità. Una categoria non è una sostituta per una sottoclasse. Ci sono molte imperfezioni significanti:&lt;ul&gt;&lt;li&gt;Quando una categoria sovrascrive un metodo ereditato, il metodo nella categoria può, come è solito, invocare l&#39;implementazione ereditata tramite un messaggio a super. Comunque, se una categoria sovrascrive un metodo che esiste già nella classe della categoria, non c&#39;è modo per invocare l&#39;implementazione originale.&lt;/li&gt;
&lt;li&gt;Una categoria non può sovrascrivere con affidabilità i metodi dichiarati in un altra categoria della stessa classe. Questo problema è particolarmente significante dato che molte delle classi Cocoa sono implementate usando le categorie. Un metodo basato su framework che provi a sovrascrivere potrebbe essere stato implementato in una categoria, e quindi non è definito quale implementazione ha la precedenza.&lt;/li&gt;
&lt;li&gt;La presena di alcuni metodi potrebbe causare cambi dei comportamenti tra tutti i frameworks. Ad esempio, se aggiungi un&#39;implementazione di windowWillClose: a NSObject, questo causerà che tutte le finestre delegate risponderanno a quel metodo e potrebbero modificare il comportamento di tutte le istanze di NSWindow. Questo potrebbe causare cambiamenti misteriosi nel comportamento e potrebbe condurre a crashes.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;h2&gt;Categorie della Classe Radice&lt;/h2&gt;&lt;div&gt;Una categoria può aggiungere metodi ad ogni classe, incluso nella classe radice. I metodi aggiunti a NSObject diventano disponibili a tutte le classi che sono collegate al tuo codice. Mentre questo può essere utile a volte, può anche essere abbastanza pericoloso. Sebbene potrebbe sembrare che le modifiche che le categorie fanno siano ben capite e di impatto limitato, l&#39;ereditarietà gli da un ampio scope. Potresti fare dei cambi non intenzionali a classi non viste; potresti non conoscere tutte le conseguenze di ciò che stai facendo. Inoltre, gli altri che non sono a conoscenza dei tuoi cambi non capiranno cosa stanno facendo.&lt;br /&gt;
&lt;br /&gt;
In aggiunta, ci sono altre due considerazioni da tenere a mente quando si implementano metodi per la classe radice:&lt;ul&gt;&lt;li&gt;Messaggi a super sono invalidi (non c&#39;è la superclasse).&lt;/li&gt;
&lt;li&gt;Gli oggetti di classe possono eseguire metodi di istanza definiti nella classe radice. &lt;/li&gt;
&lt;/ul&gt;Normalmente gli oggetti di classe possono eseguire solo metodi di classe. Ma i metodi di istanza definiti nella classe radice sono un caso speciale. Essi definiscono un&#39;interfaccia al sistema di runtime che tutti gli oggetti ereditano. Gli oggetti di classe sono oggetti full-fledged e devono condividere la stessa interfaccia.&lt;br /&gt;
&lt;br /&gt;
Questa caratteristica significa che hai bisogno di tener conto della possibilità che un metodo di istanza che definisci in una categoria della classe NSObject potrebbe essere eseguito non solo da istanze ma da anche da oggetti di classe. Ad esempio, nel corpo del metodo, self potrebbe significare un oggetto di classe così come un&#39;istanza. &lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Estensioni&lt;/h2&gt;&lt;div&gt;Le estensioni di classi sono come categorie &quot;anonime&quot;, tranne che i metodi che dichiarano devono essere implementati nel blocco principale @implementation per la classe corrispondente.&lt;br /&gt;
&lt;br /&gt;
&amp;Egrave; comune per una classe avere un&#39;API pubblicamente dichiarata e poi avere API aggiuntiva dichiarata privatamente per solo uso della classe o del framework dentro il quale risiede la classe. Puoi dichiarare tale API in una categoria (o in più di una categoria) in un file header privato o in un file di implementazione come descritto sopra. Questo funziona, ma il compilatore non può verificare che tutti i metodi dichiarati siano implementati.&lt;br /&gt;
&lt;br /&gt;
Ad esempio, il compilatore compilerà senza errori le seguenti dichiarazioni e implementazioni:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface MyObject : NSObject&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
NSNumber *number;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSNumber *)number;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@interface MyObject (Setter)&lt;br /&gt;
&lt;br /&gt;
- (void)setNumber:(NSNumber *)newNumber;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation MyObject&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (NSNumber *)number {&lt;br /&gt;
&lt;br /&gt;
return number;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Nota che non c&#39;è implementazione del metodo setNumber:. Se è invocato a runtime genererà un errore.&lt;br /&gt;
&lt;br /&gt;
Le estensioni di classe ti permettono di dichiarare API aggiuntive richieste per una classe in locazioni diverse da dentro al blocco primario @interface della classe, come illustrato nel seguente esempio:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface MyObject : NSObject&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
NSNumber *number;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (NSNumber *)number;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@interface MyObject ()&lt;br /&gt;
&lt;br /&gt;
- (void)setNumber:(NSNumber *)newNumber;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation MyObject&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (NSNumber *)number {&lt;br /&gt;
&lt;br /&gt;
return number;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (void)setNumber:(NSNumber *)newNumber {&lt;br /&gt;
&lt;br /&gt;
number = newNumber;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Nota che in questo caso:&lt;ul&gt;&lt;li&gt;Non è dato un nome nelle parentesi nel secondo blocco @interface;&lt;br /&gt;
&lt;li&gt;L&#39;implementazione del metodo setNumber: appare dentro al blocco @implementation princpiale della classe.&lt;/ul&gt;L&#39;implementazione del metodo setNumber. deve apparire dentro al blocco @implementation princpale della classe (non poui implementarlo in una categoria). Se questo non è il caso, il compilatore emetterà un warning avvisando che non può trovare una definizione di metodo per setNumber:. &lt;/div&gt;&lt;hr&gt;&lt;h2&gt;Fine Settima Parte&lt;/h2&gt;&lt;div&gt;Finisce qui il settimo articolo di questa Guida dedicato alle Categorie e Estensioni del linguaggio di programmazione Objective-C. Spero col tempo di realizzare un&#39;utile manuale disponibile a tutti. Il prossimo post di questa guida, tratterà i Riferimenti Associativi, un utile strumento per simulare l&#39;aggiunta di variabili di istanza di un oggetto ad una classe esistente. Segnalatemi eventuali errori, o commentate l&#39;articolo se l&#39;avete trovato utile, anche per incentivarmi a continuare a pubblicare le mie traduzioni. Iscrivetevi ai feed del blog per essere sempre aggiornati automaticamente ogni volta che sono disponibili nuovi contenuti. Nella barra laterale del blog potete trovare l&#39;elenco di tutti gli articoli di questa guida.&lt;/div&gt;&lt;/span&gt;&lt;!-- &lt;/EdIndex&gt; --&gt;  &lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/04/guida-objective-c-in-italiano-parte-7.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-909986217526934824</guid><pubDate>Wed, 28 Apr 2010 17:06:00 +0000</pubDate><atom:updated>2010-04-28T19:12:09.755+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">proprietà</category><category domain="http://www.blogger.com/atom/ns#">synthesize</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - Parte 6 - Le proprietà Dichiarate</title><description>&lt;!-- &lt;edindex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align:justify;&quot;&gt;In questa sesta parte della Guida alla programmazione in Objective-C parleremo delle proprietà dichiarate delle classi, come si dichiarano, come si implementano, come si usano e come si sintetizzano automaticamente i loro metodi accessori.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2&quot; title=&quot;Guida Originale in Inglese&quot;&gt;questo link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questo articolo può interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;br /&gt;
&lt;/div&gt;&lt;hr&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;br /&gt;
&lt;h2&gt;Proprietà Dichiarate&lt;/h2&gt;&lt;div&gt;Le proprietà dichiarate Objective-C fornisce un semplice modo di dichiarare ed implementare i metodi accessori di un metodo.&lt;/div&gt;&lt;h2&gt;Anteprima&lt;/h2&gt;&lt;div&gt;Questi sono due aspetti di questa caratteristica del linguaggio: gli elementi sintattici che usi per specificare e sintetizzare le proprietà dichiarate, e un elemento sintattico collegato che sarà descritto in &quot;Sintassi Punto&quot;.&lt;br /&gt;
&lt;br /&gt;
Tipicamente accedi alle proprietà di un oggetto (i suoi attributi e relazioni) attraverso una coppia di metodi accessori (getter e setter). Usando i metodi accessori, aderisci al principio dell&#39;incapsulamento. Puoi esercitare uno stretto controllo del comportamento della coppia getter/setter e della gestione dello stato di fondo mentre i clients delle API restano isolati dai cambiamenti dell&#39;implementazione.&lt;br /&gt;
&lt;br /&gt;
Sebbene usare metodi accessori abbia vantaggi significativi, scrivere metodi accessori  è un processo noioso - in particolare se devi scrivere codice per supportare entrambi ambienti garbage collected e reference counted. Inoltre, aspetti delle proprietà che possono essere importanti per i clienti delle API sono lasciate oscurate  - come se i metodi accessori fossero thread-safe o se nuovi valori sono copiati quando si impostano.&lt;br /&gt;
&lt;br /&gt;
Le proprietà dichiarate indirizzano i problemi con metodi accessori standard fornendo le seguenti caratteristiche:&lt;ul&gt;&lt;li&gt;La dichiarazione di proprietà fornisce una chiara, ed esplicita specifica di come i metodi accessori si comportano.&lt;/li&gt;
&lt;li&gt;Il compilatore può sintetizzare i metodi accessori per te, in accordo alla specifica da te fornita nella dichiarazione. Questo significa che hai meno codice da scrivere e mantenere.&lt;/li&gt;
&lt;li&gt;Le proprietà sono rappresentate sintatticamente come identificatori e hanno uno scope, quindi il compilatore può identificare un uso di proprietà non dichiarate.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;h2&gt;Dichiarazione di Proprietà e Implementazione&lt;/h2&gt;&lt;div&gt;Ci sono due parti di una proprietà dichiarata, la sua dichiarazione e la sua implementazione.&lt;/div&gt;&lt;h2&gt;Dichiarazione di Proprietà&lt;/h2&gt;&lt;div&gt;Una dichiarazione di proprietà inizia con la parola chiave @property. @property può apparire ovunque nella lista della dichiarazione dei metodi trovata nella @interface di una classe. @property può anche apparire nella dichiarazione di un protocollo o di una categoria.&lt;br /&gt;
&lt;br /&gt;
@property(attributes) type name;&lt;br /&gt;
&lt;br /&gt;
@property dichiara una proprietà. Una insieme opzionale di attributi tra parentesi, fornisce dettagli aggiuntivi riguardo alle semantiche di memoria e altri comportamenti della proprietà. Come ogni altro tipo Objective-C, ogni proprietà ha una specifica di tipo ed un nome.&lt;br /&gt;
&lt;br /&gt;
Il listato 5-1 illustra la dichiarazione di una semplice proprietà.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Listato 5-1&lt;/b&gt;  Dichiarazione di una semplice proprietà&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface MyClass : NSObject&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
float value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@property float value;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Puoi pensare che una dichiarazione di proprietà sia l&#39;equivalente a dichiarare due metodi accessori. Così&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@property float value;&lt;/div&gt;&lt;div&gt;è equivalente a:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (float)value;&lt;br /&gt;
&lt;br /&gt;
- (void)setValue:(float)newValue;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Una dichiarazione di proprietà comunque, fornisce informazioni aggiuntive su come i metodi accessori sono implementati, come descritto in Attributi di dichiarazioni di proprietà.&lt;/div&gt;&lt;h2&gt;Attributi di Dichiarazioni di Proprietà&lt;/h2&gt;&lt;div&gt;Potete decorare una proprietà con degli attributi usando la forma @property(attribute [, attribute2, ...]). Come i metodi, le proprietà hanno lo scope nella dichiarazione di interfaccia che le racchiude. Per le dichiarazioni di proprietà che usano una lista di nomi di variabili delimitata da virgole, gli attributi di proprietà si applicano a tutte le proprietà nominate. &lt;br /&gt;
&lt;br /&gt;
Se usi la direttiva @synthesize per dire al compilatore di creare i metodi accessori, il codice che genera combacerà con la specifica data dalle parolechiave. Se implementi i metodi accessori per conto tuo, dovresti appunto assicurarti che combacino con la specifica (ad esempio, se specifichi &quot;copy&quot;, ti devi assicurare che effettivamente copi il valore di input nel metodo setter).&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Nomi dei Metodi Accessori&lt;/h2&gt;&lt;div&gt;I nomi di default per i metodi getter e setter associati ad una proprietà, sono &quot;nomeProprietà&quot; e &quot;setNomeProprietà:&quot; rispettivamente - ad esempio, avendo una proprietà &quot;foo&quot;, gli accessori sarebbero foo e setFoo:. Gli attributi seguenti permettono invece di specificare nomi personalizzati. Sono entrambi opzionali e potrebbero apparire con qualunque altro attributo (tranne per readonly nel caso di setter=).&lt;br /&gt;
&lt;br /&gt;
getter=getterName&lt;br /&gt;
Specifica il nome del metodo accessorio get per la proprietà. Il getter deve restituire un tipo che combacia con il tipo della proprietà e non prendere argomenti.&lt;br /&gt;
&lt;br /&gt;
setter=setterName&lt;br /&gt;
Specifica il nome del metodo accessorio set per la proprietà. Il metodo setter deve prendere un singolo argomento il cui tipo combaci con il tipo della proprietà e deve restituire void. &lt;br /&gt;
Se specifichi che una proprietà è readonly allora specifichi anche un setter con setter=, otterrai un warning dal compilatore.&lt;br /&gt;
&lt;br /&gt;
Tipicamente dovresti specificare i nomi dei metodi accessori che sono chiave-valore codifica compiacente - una ragione comune per usare il decoratore getter è di aderire alla convenzione isNomeProprietà per valori booleani.&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Scrivibilità&lt;/h2&gt;&lt;div&gt;Questi attributi specificano se una proprietà ha un metodo accessorio set associato o meno.  Sono mutuamente esclusivi.&lt;br /&gt;
&lt;br /&gt;
readwrite&lt;br /&gt;
Indica che la proprietà dovrebbe essere trattata come read/write. Questa è l&#39;opzione di default.&lt;br /&gt;
Entrambi i metodi getter e setter saranno richiesti nella @implementation. Se usi @synthesize nel blocco implementazione, i metodi getter e setter saranno sintetizzati.&lt;br /&gt;
&lt;br /&gt;
readonly&lt;br /&gt;
Indicache la proprietà è read-only.&lt;br /&gt;
Se specifichi readonly, sarà richiesto solo un metodo getter nella @implementation. Se usi @synthesize nel blocco dell&#39; implementazione, sarà sintetizzato solo il metodo  getter. Inoltre, se provi ad assegnare un valore usando la sintassi punto, ottieni un errore di compilazione.&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Semantica Setter&lt;/h2&gt;&lt;div&gt;Questi attributi specificano le semantiche di un accessorio set. Sono mutualmente esclusive.&lt;br /&gt;
&lt;br /&gt;
assign&lt;br /&gt;
Specifica che il setter usa un assegnamento semplice. Questo è di default.&lt;br /&gt;
Tipicamente usi questo attributo per tipi scalari come NSInteger e CGRect, o (in un ambiente reference-counted) per oggetti di cui non sei il proprietario come i delegati.&lt;br /&gt;
&lt;br /&gt;
retain ed assign sono praticamente la stessa cosa in ambienti garbage-collected.&lt;br /&gt;
&lt;br /&gt;
retain&lt;br /&gt;
Specifica che dovrebbe essere invocato retain sull&#39;oggetto sotto assegnamento. (Di default è assign.) Il valore precedente è inviato a un messaggio release.&lt;br /&gt;
Prima di Mac OS X v10.6, questo attributo era valido solo per tipi di oggetti Objective-C (quindi non puoi specificare retain per oggetti di Core Foundation).&lt;br /&gt;
&lt;br /&gt;
Su Mac OS X v10.6 e successivi, puoi usare __attributo__ parolachiave per specificare che una proprietà del Core Foundation dovrebbe essere trattata come un oggetto Objective-C per la gestione della memoria, come illustrato in questo esempio:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@property(retain) __attribute__((NSObject)) CFDictionaryRef myDictionary;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;copy&lt;br /&gt;
Specifica che una copia dell&#39;oggetto dovrebbe essere usata per l&#39;assegnamento (di default è assign). Il valore precedente è inviato a un messaggio release.&lt;br /&gt;
La copia è fatta invocando il metodo copy. Questo attributo è valido solo per tipi di oggetti, che devono implementare il protocolo NSCopying.&lt;br /&gt;
&lt;br /&gt;
Si applicano vincoli differenti a seconda di se si usa la garbage collection o no:&lt;ul&gt;&lt;li&gt;Se non usi la garbage collection, per le proprietà degli oggetti devi esplicitamente specificare uno tra assign, retain o copy - altrimenti avrai un warning dal compilatore. (Questo ti incoraggia a pensare su che tipo di comportamento vuoi per la gestione della memoria e a digitarlo esplicitamente). Per decidere quale dovresti scegliere, devi capire le politiche di gestione memoria di Cocoa (Vedi Memory Management Programming Guide for Cocoa).&lt;/li&gt;
&lt;li&gt;Se usi la garbage collection, non otterrai un warning se usi il default (che è, se non specifichi nulla tra assign, retain o copy) a meno che il tipo della proprietà sia una classe conforme ad NSCopying. Il default è di solito quello che vuoi; se il tipo della proprietà può essere copiato, comunque, per preservare l&#39;incapsulamento spesso vorrai fare una copia privata dell&#39;oggetto.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;h2&gt;Atomicità&lt;/h2&gt;&lt;div&gt;Questo attributo specifica che i metodi accessori non sono atomici. (non c&#39;è una parola chiave per denotare atomico).&lt;br /&gt;
&lt;br /&gt;
nonatomic&lt;br /&gt;
Specifica che i metodi accessori sono non-atomici. Di default, i metodi accessori sono atomici.&lt;br /&gt;
Le proprietà sono atomiche di default quindi i loro metodi accessori sintetizzati forniscono un accesso robusto alle proprietà in un ambiente multi-threaded - che è, il valore restituito dal getter o settato tramite il setter è sempre pienamente recuperato o impostato senza curarsi di quali altri threads sono concorrentemente in esecuzione.&lt;br /&gt;
&lt;br /&gt;
Se non specifichi nonatomic, allora in un ambiente reference counted, un metodo accessorio sintetizzato per una proprietà di un oggetto usa un lock e conserva e autorilascia il valore restituito - l&#39;implementazione sarà simile alla seguente:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;[_internal lock]; // lock using an object-level lock&lt;br /&gt;
&lt;br /&gt;
id result = [[value retain] autorelease];&lt;br /&gt;
&lt;br /&gt;
[_internal unlock];&lt;br /&gt;
&lt;br /&gt;
return result;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Se specifichi nonatomic, allora un accessorio sintetizzato per una proprietà di un oggetto semplicemente restituisce il valore direttamente.&lt;/div&gt;&lt;h2&gt;Markup e Deprecazione&lt;/h2&gt;&lt;div&gt;Le proprietà supportano la piena gamma di decoratori di stile C. Le proprietà possono essere deprecate e supportare  attributi di markup di stile __attribute__ , come illustrato nel seguente esempio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@property CGFloat x&lt;br /&gt;
&lt;br /&gt;
AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;&lt;br /&gt;
&lt;br /&gt;
@property CGFloat y __attribute__((...));&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Se vuoi specificare che una proprietà è un&#39;outlet di Interface Builder, puoi usare l&#39;identificatore IBOutlet:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@property (nonatomic, retain) IBOutlet NSButton *myButton;&lt;/div&gt;&lt;div&gt;IBOutlet non è una parte formale della lista degli attributi.&lt;br /&gt;
&lt;br /&gt;
Se usi la garbage collection, puoi usare modificatori di storage come  __weak e __strong in una dichiarazione di proprietà:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@property (nonatomic, retain) __weak Link *parent;&lt;/div&gt;&lt;div&gt;ma non sono una parte formale della lista degli attributi.&lt;/div&gt;&lt;h2&gt;Direttive di Implementazione di Proprietà&lt;/h2&gt;&lt;div&gt;Puoi usare le direttive @synthesize e @dynamic nei blocchi @implementation per innescare specifiche azioni del compilatore. Nota che nessuna delle due è richiestaper qualunque dichiarazione di @property data.&lt;br /&gt;
&lt;br /&gt;
Importante: se non specifichi nè @synthesize nè @dynamic per una particolare proprietà, devi fornire un&#39;implementazione dei metodi getter e un setter (o solo du un getter nel caso di una proprietà readonly) per questa proprietà.&lt;br /&gt;
&lt;br /&gt;
@synthesize&lt;br /&gt;
Usi la parola chiave @synthesize per dire al compilatore che dovrebbe sintetizzare i metodi setter e/o getter per la proprietà se non li fornisci nel blocco @implementagion.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Listato 5-2&lt;/b&gt;  Usare @synthesize&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface MyClass : NSObject&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
NSString *value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@property(copy, readwrite) NSString *value;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation MyClass&lt;br /&gt;
&lt;br /&gt;
@synthesize value;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Puoi usare la forma property=ivar per indicare che una particolare variabile di istanza dovrebbe essere usata per la proprietà, ad esempio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@synthesize firstName, lastName, age = yearsOld;&lt;/div&gt;&lt;div&gt;Questo specifica che i metodi accessori per firstName, lastName, e age dovrebbero essere sintetizzati e che la proprietà age è rappresentata dalla variabile di istanza yearsOld.&lt;br /&gt;
&lt;br /&gt;
Se specifichi o no il nome della variabile di istanza, @synthesize può solo usare una variabile di istanza dalla classe corrente, non una superclasse.&lt;br /&gt;
&lt;br /&gt;
Ci sono differenze nel comportamento che dipendono dal runtime:&lt;ul&gt;&lt;li&gt;Per i runtime a eredità, le variabili di istanza devono già essere dichiarate nel blocco @interface della classe corrente. Se una variabile di istanza dello stesso nome e di tipo compatibile a quello della proprietà esiste, è usata - altrimenti, otterrai un errore di compilazione.&lt;/li&gt;
&lt;li&gt;Per i runtime moderni, le variabili di istanza sono sintetizzate come serve. Se esiste già una variabile di istanza con lo stesso nome, è usata.&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
@dynamic&lt;br /&gt;
Si usa la parola chiave @dynamic per dire al compilatore che  adempirete al contratto delle API implicito da una proprietà o fornendo implementazioni di metodi direttamente, o  a runtime usando altri meccanismi come il caricamento dinamico del codice o risoluzione di metodo dinamico. L&#39;esempio mostrato nel listato 5-3 illustra l&#39;uso delle implementazioni dirette di metodo - equivalente all&#39;esempio del listato 5-2.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Listato 5-3&lt;/b&gt;  Usare @dynamic con implementazioni dirette di metodo &lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface MyClass : NSObject&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
NSString *value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@property(copy, readwrite) NSString *value;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// assume using garbage collection&lt;br /&gt;
&lt;br /&gt;
@implementation MyClass&lt;br /&gt;
&lt;br /&gt;
@dynamic value;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (NSString *)value {&lt;br /&gt;
&lt;br /&gt;
return value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (void)setValue:(NSString *)newValue {&lt;br /&gt;
&lt;br /&gt;
if (newValue != value) {&lt;br /&gt;
&lt;br /&gt;
value = [newValue copy];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h2&gt;Usare le Proprietà&lt;/h2&gt;&lt;h2&gt;Tipi Supportati&lt;/h2&gt;&lt;div&gt;Puoi dichiarare una proprietà per qualunque classe Objective-C, tipo di dati Core Foundation o tipi &quot;plain old data&quot; (POD).&lt;/div&gt;&lt;h2&gt;Ri-dichiarazione di Proprietà &lt;/h2&gt;&lt;div&gt;Puoi re-dichiarare una proprietà in una sottoclasse, ma (ad eccezione di readonly contro readwrite) devi ripetere i suoi attributi per intero nelle sottoclassi. Vale lo stesso per una proprietà dichiarata in una categoria o in un protocollo - mentre le proprietà possono essere re-dichiarate in una categoria o protocollo, gli attributi di proprietà devono essere ripetute per intero.&lt;br /&gt;
&lt;br /&gt;
Se dichiari una proprietà readonly in una classe, puoi re-dichiararla come readwrite in un estensione di classe , un protocollo o una sottoclasse. Nel caso di un&#39;estensione re-dichiarazione di classe, il fatto che la proprietà era re-dichiarata prima di ogni statement @synthesize causerà la sintetizzazione del setter. L&#39;abilità di re-dichiarare una proprietà readonly come read/write abilita due pattern di implementazioni comuni: una sottoclasse mutabile di una classe immutabile (NSstring, NSarray, e NSDictionary sono tutti esempi) e una proprietà che ha API pubbliche che è readonly ma ha un&#39;implementazione readwrite privata interna alla classe. Il seguente esempio mostra l&#39;uso di un estensione di classe per fornire una proprietà che è dichiarata come readonly nell&#39;header pubblico ma che è re-dichiarata privatamente come read/write.&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;// public header file&lt;br /&gt;
&lt;br /&gt;
@interface MyObject : NSObject {&lt;br /&gt;
&lt;br /&gt;
NSString *language;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@property (readonly, copy) NSString *language;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// private implementation file&lt;br /&gt;
&lt;br /&gt;
@interface MyObject ()&lt;br /&gt;
&lt;br /&gt;
@property (readwrite, copy) NSString *language;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation MyObject&lt;br /&gt;
&lt;br /&gt;
@synthesize language;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h2&gt;Copy&lt;/h2&gt;&lt;div&gt;Se usi l&#39;attributo di dichiarazione copy, specifichi che un valore è copiato durante l&#39;assegnamento. Se sintetizzi l&#39;accessorio corrispondente, il metodo sintetizzato usa il metodo copy. Questo è utile per attributi come oggetti String dove c&#39;è una possibilità che il nuovo valore passato ad un setter potrebbe essere mutabile (ad esempio, un istanza di NSMutableString) e tu vuoi assicurarti che il tuo oggetto ha la sua copia privata immutabile. Ad esempio, se dichiari una proprietà come segue:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@property (nonatomic, copy) NSString *string;&lt;/div&gt;&lt;div&gt;allora il metodo setter sintetizzato è simile al seguente:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;-(void)setString:(NSString *)newString {&lt;br /&gt;
&lt;br /&gt;
if (string != newString) {&lt;br /&gt;
&lt;br /&gt;
[string release];&lt;br /&gt;
&lt;br /&gt;
string = [newString copy];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Sebbene questo funzioni bene per le stringhe, potrebbe presentare un problema se l&#39;attributo è una collezione come un array o un insieme. Tipicamente vuoi che queste collezioni siano mutabili, ma il metodo copy restituisce una versione immutabile della collezione. In questa situazione devi fornire una tua propria implementazione del metodo setter, come illustrato nel seguente esempio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface MyClass : NSObject {&lt;br /&gt;
&lt;br /&gt;
NSMutableArray *myArray;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@property (nonatomic, copy) NSMutableArray *myArray;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation MyClass&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@synthesize myArray;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (void)setMyArray:(NSMutableArray *)newArray {&lt;br /&gt;
&lt;br /&gt;
if (myArray != newArray) {&lt;br /&gt;
&lt;br /&gt;
[myArray release];&lt;br /&gt;
&lt;br /&gt;
myArray = [newArray mutableCopy];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;dealloc&lt;/h2&gt;&lt;div&gt;Le proprietà dichiarate fondamentalmente prendono il posto delle dichiarazioni dei metodi accessori; quando sintetizzi una proprietà il compilatore crea soltanto qualsiasi metodo accessorio assente. Non c&#39;è interazione diretta con il metodo dealloc - le proprietà non sono automaticamente rilasciate per te. Le proprietà dichiarate forniscono un utile metodo per controllare incrociatamente l&#39;implementazione del metodo dealloc: Puoi cercare tutte le dichiarazioni di proprietà nel tuo file header e assicurarti che le proprietà dell&#39;oggetto NON marcate con assign siano rilasciate, e quelle marcate con assign non siano rilasciate.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Nota:&lt;/b&gt; Tipicamente in un metodo dealloc dovresti rilasciare variabili di istanza di un oggetto direttamente (invece che invocare un metodo accessorio set passandogli nil come parametro), come illustrato in questo esempio:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (void)dealloc {&lt;br /&gt;
&lt;br /&gt;
[property release];&lt;br /&gt;
&lt;br /&gt;
[super dealloc];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Se stai usando il runtime moderno e sintetizzando le variabili di istanza, non puoi accedere alle variabili di istanza diretatmente, quindi devi invocare il metodo accessorio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (void)dealloc {&lt;br /&gt;
&lt;br /&gt;
[self setProperty:nil];&lt;br /&gt;
&lt;br /&gt;
[super dealloc];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Core Foundation&lt;/h2&gt;&lt;div&gt;Come già detto prima, prima di Mac OS X v10.6 non si poteva specificare l&#39;attributo retain per tipi di non-oggetti. Se, quindi dichiari una proprietà il cui tipo è un CFType (Core Foundation Type) e sintetizzi i metodi accessori come illustrato nel seguente esempio:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface MyClass : NSObject&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
CGImageRef myImage;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@property(readwrite) CGImageRef myImage;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation MyClass&lt;br /&gt;
&lt;br /&gt;
@synthesize myImage;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;allora in un ambiente reference counted il metodo set generato assegnerà semplicemente il nuovo valore alla variabile di istanza (il nuovo valore non è conservato e il vecchio valore non è rilasciato). Questo è tipicamente incorretto, quindi non dovreste sintetizzare i metodi ma  dovreste implementarli voi.&lt;br /&gt;
&lt;br /&gt;
In un ambiente garbage collected, se la variabile è dichiarata __strong:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;...&lt;br /&gt;
&lt;br /&gt;
__strong CGImageRef myImage;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
@property CGImageRef myImage;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;allora gli accessori sono sintetizzati appropriatamente - l&#39;immagine non sarà CFRetain, ma il setter attiverà una barriera di scrittura. &lt;/div&gt;&lt;h2&gt;Esempio&lt;/h2&gt;&lt;div&gt;Il seguente esempio illustra l&#39;uso di proprietà in molti modi diversi:&lt;br /&gt;
Il protocollo Link dichiara una proprietà, next.&lt;ul&gt;&lt;li&gt;MyClass adotta il protocollo Link quindi dichiara implicitamente anche la proprietà next. MyClass dichiara anche diverse altre proprietà.&lt;/li&gt;
&lt;li&gt;creationTimestamp e next sono sintetizzate ma usano variabili di istanza esistenti con nomi diversi;&lt;/li&gt;
&lt;li&gt;name è sintetizzato, e usa sintesi di variabile di istanza (richiamare quella sintesi della variabile di istanza non è supportato dal legacy runtime;&lt;/li&gt;
&lt;li&gt;gratuitousFloat ha una direttiva dynamic — è supportata usando l&#39;implementazione diretta dei metodi;&lt;/li&gt;
&lt;li&gt;nameAndAge non ha una direttiva dynamic,  ma questo è il valore di default; è supportato usando un&#39;implementazione diretta dei metodi (dato che è readonly, richiede solo un getter) con un nome specificato (nameAndAgeAsString).&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;Listato 5-4&lt;/b&gt;  Dichiarare proprietà per una classe&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@protocol Link&lt;br /&gt;
&lt;br /&gt;
@property id &amp;lt;Link&amp;gt; next;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@interface MyClass : NSObject &amp;lt;Link&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
NSTimeInterval intervalSinceReferenceDate;&lt;br /&gt;
&lt;br /&gt;
CGFloat gratuitousFloat;&lt;br /&gt;
&lt;br /&gt;
id &amp;lt;Link&amp;gt; nextLink;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@property(readonly) NSTimeInterval creationTimestamp;&lt;br /&gt;
&lt;br /&gt;
@property(copy) NSString *name;&lt;br /&gt;
&lt;br /&gt;
@property CGFloat gratuitousFloat;&lt;br /&gt;
&lt;br /&gt;
@property(readonly, getter=nameAndAgeAsString) NSString *nameAndAge;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation MyClass&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@synthesize creationTimestamp = intervalSinceReferenceDate, name;&lt;br /&gt;
&lt;br /&gt;
// Synthesizing &#39;name&#39; is an error in legacy runtimes;&lt;br /&gt;
&lt;br /&gt;
// in modern runtimes, the instance variable is synthesized.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@synthesize next = nextLink;&lt;br /&gt;
&lt;br /&gt;
// Uses instance variable &quot;nextLink&quot; for storage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@dynamic gratuitousFloat;&lt;br /&gt;
&lt;br /&gt;
// This directive is not strictly necessary.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (CGFloat)gratuitousFloat {&lt;br /&gt;
&lt;br /&gt;
return gratuitousFloat;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
- (void)setGratuitousFloat:(CGFloat)aValue {&lt;br /&gt;
&lt;br /&gt;
gratuitousFloat = aValue;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (NSString *)nameAndAgeAsString {&lt;br /&gt;
&lt;br /&gt;
return [NSString stringWithFormat:@&quot;%@ (%fs)&quot;, [self name],&lt;br /&gt;
&lt;br /&gt;
[NSDate timeIntervalSinceReferenceDate] - intervalSinceReferenceDate];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (id)init {&lt;br /&gt;
&lt;br /&gt;
if (self = [super init]) {&lt;br /&gt;
&lt;br /&gt;
intervalSinceReferenceDate = [NSDate timeIntervalSinceReferenceDate];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return self;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (void)dealloc {&lt;br /&gt;
&lt;br /&gt;
[nextLink release];&lt;br /&gt;
&lt;br /&gt;
[name release];&lt;br /&gt;
&lt;br /&gt;
[super dealloc];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Sottoclassi con Proprietà&lt;/h2&gt;&lt;div&gt;Puoi sovrascrivere una proprietà readonly per renderla scrivibile. Ad esempio, potresti definire una classe MyInteger con una proprietà readonly, value:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface MyInteger : NSObject&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
NSInteger value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@property(readonly) NSInteger value;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation MyInteger&lt;br /&gt;
&lt;br /&gt;
@synthesize value;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Potresti poi implementare una sottoclasse, MyMutableInteger, che ridefinisce la proprietà per renderla scrivibile:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface MyMutableInteger : MyInteger&lt;br /&gt;
&lt;br /&gt;
@property(readwrite) NSInteger value;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation MyMutableInteger&lt;br /&gt;
&lt;br /&gt;
@dynamic value;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (void)setValue:(NSInteger)newX {&lt;br /&gt;
&lt;br /&gt;
value = newX;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Prestazioni e Threading&lt;/h2&gt;&lt;div&gt;Se fornisci la tua implementazione dei metodi, il fatto che dichiari una proprietà non ha effetto sulla sua efficienza o sulla sicurezza del thread.&lt;br /&gt;
&lt;br /&gt;
Se usi proprietà sintetizzate, le implementazioni di metodo generate dal compilatore dipendono dalla specifica che fornisci. Gli attributi di dichiarazione che influenzano le prestazioni ed il threading sono retain, assign, copy, e nonatomic. Le prime tre influenzano soltanto la parte dell&#39;implementazione dell&#39;assegnamento del metodo set, come illustrato sotto (l&#39;implementazione potrebbe non essere esattamente come mostrato):&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;// assign&lt;br /&gt;
&lt;br /&gt;
property = newValue;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// retain&lt;br /&gt;
&lt;br /&gt;
if (property != newValue) {&lt;br /&gt;
&lt;br /&gt;
[property release];&lt;br /&gt;
&lt;br /&gt;
property = [newValue retain];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// copy&lt;br /&gt;
&lt;br /&gt;
if (property != newValue) {&lt;br /&gt;
&lt;br /&gt;
[property release];&lt;br /&gt;
&lt;br /&gt;
property = [newValue copy];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;L&#39;effetto dell&#39;attributo nonatomic dipende dall&#39;ambiente. Di default, gli accessori sintetizzati sono atomici. In un ambiente reference counted, garantire comportamenti atomici richiede l&#39;uso di una chiusura; inoltre un oggetto restituito è conservato e autorilasciato, come abbiamo già visto precedentemente. Se tali accessori sono invocati frequentemente, questo potrebbe avere un impatto significante sulle prestazioni. In un ambiente garbage collected, la maggior parte dei metodi sintetizzati sono atomici.&lt;br /&gt;
&lt;br /&gt;
&amp;Egrave; importante capire che l&#39;obbiettivo dell&#39;implementazione atomica è fornire robusti metodi accessori - non garantisce correttezza del codice. Sebbene &quot;atomic&quot; significa che l&#39;accesso alla proprietà è thread-safe, rendere atomiche tutte le proprietà della tua classe non vuol dire che la tua classe o piu generalmente il grafico del tuo oggetto sia &quot;thread safe&quot; - la sicurezza del thread non può essere espressa al livello di metodi accessori individuali.&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Differenze di Runtime&lt;/h2&gt;&lt;div&gt;In generale il comportamento delle proprietà è identico su tutti i runtimes. C&#39;è una differenza chiave: il runtime moderno supporta sintesi di variabili di istanza e il legacy runtime no.&lt;br /&gt;
&lt;br /&gt;
Per far funzionare @synthesize nel legacy runtime, devi fornire una variabile di istanza con lo stesso nome e di tipo compatibile con la proprietà o specificare un altra variabile di istanza esistente nello statement @synthesize. con il runtime moderno, non fornisci una variabile di istanza, il compilatore ne aggiunge una per te. Ad esempio, data la seguente dichiarazione e implementazione di classe:&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface MyClass : NSObject {&lt;br /&gt;
&lt;br /&gt;
float sameName;&lt;br /&gt;
&lt;br /&gt;
float otherName;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@property float sameName;&lt;br /&gt;
&lt;br /&gt;
@property float differentName;&lt;br /&gt;
&lt;br /&gt;
@property float noDeclaredIvar;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@implementation MyClass&lt;br /&gt;
&lt;br /&gt;
@synthesize sameName;&lt;br /&gt;
&lt;br /&gt;
@synthesize differentName=otherName;&lt;br /&gt;
&lt;br /&gt;
@synthesize noDeclaredIvar;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Il compilatore per il runtime legacy dovrebbe generare un errore a @synthesize noDeclaredIvar; considerando che il compilatore per il runtime moderno aggiungerebbe una variabile di istana per rappresentare noDeclaredIvar.&lt;/div&gt;&lt;hr&gt;&lt;br /&gt;
&lt;h2&gt;Fine Sesta Parte&lt;/h2&gt;&lt;div&gt;Finisce qui il sesto articolo di questa Guida dedicato alle Proprietà Dichiarate delle classi del linguaggio di programmazione Objective-C. Spero col tempo di realizzare un&#39;utile manuale disponibile a tutti. Il prossimo post di questa guida, tratterà le Categorie e le Estensioni. Segnalatemi eventuali errori, o commentate l&#39;articolo se l&#39;avete trovato utile, anche per incentivarmi a continuare a pubblicare le mie traduzioni. Iscrivetevi ai feed del blog per essere sempre aggiornati automaticamente ogni volta che sono disponibili nuovi contenuti. nella colonna a destra di questo blog potete trovare tutti i link agli articoli di questa guida.&lt;/div&gt;&lt;/span&gt; &lt;!-- &lt;/edindex&gt; --&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/04/guida-objective-c-in-italiano-parte-6.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-5228473402380264414</guid><pubDate>Mon, 19 Apr 2010 20:59:00 +0000</pubDate><atom:updated>2010-04-19T22:59:12.139+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">i protocolli</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - Parte 5 - I Protocolli</title><description>&lt;!-- &lt;EdIndex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Siamo arrivati alla quinta parte della Guida all&#39;Objective-C, negli articoli precedenti abbiamo parlato a lungo dei concetti base del linguaggio quali, &lt;a href=&quot;http://emdief.blogspot.com/2010/04/guida-objective-c-in-italiano-le-basi.html&quot;&gt;gli Oggetti&lt;/a&gt;, &lt;a href=&quot;http://emdief.blogspot.com/2010/04/guida-objective-c-in-italiano-le-classi.html&quot;&gt;le Classi&lt;/a&gt;, &lt;a href=&quot;http://emdief.blogspot.com/2010/04/guida-objective-c-in-italiano-creare.html&quot;&gt;la definizione di Classi e Interfacce&lt;/a&gt;, e &lt;a href=&quot;http://emdief.blogspot.com/2010/04/guida-objective-c-in-italiano-allocare.html&quot;&gt;l&#39;inizializzazione degli Oggetti&lt;/a&gt;. Oggi vi faremo luce su tutti gli aspetti di un utile strumento di questo linguaggio che è rappresentato dai Protocolli.&lt;br /&gt;
&lt;br /&gt;
Ricordo che il presente post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a questo &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html#//apple_ref/doc/uid/TP30001163-CH22-SW1&quot; title=&quot;Articolo originale in Inglese&quot;&gt;link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questa guida potrebbe interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;/div&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;h2&gt;Protocolli&lt;/h2&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;I protocolli dichiarano metodi che possono essere implementati in ogni classe. I protocolli sono utili in almeno tre situazioni:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Per dichiarare metodi che altri pensano di implementare&lt;/li&gt;
&lt;li&gt;Per dichiarare l&#39;interfaccia a un oggetto e nasconderla alla sua classe&lt;/li&gt;
&lt;li&gt;Per catturare similarità tra le classi che non sono correlate gerarchicamente.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;h2&gt;Dichiarare Interfacce da far implementare agli altri&lt;/h2&gt;&lt;div&gt;Classe e categoria di interfacce dichiarano metodi che sono associati con una classe particolare - metodi principali che la classe implementa. Protocolli formali e informali, d&#39;altro canto, dichiarano metodi che sono indipendenti da qualunque classe specifica, ma che qualunque classe, e forse molte classi, potrebbero implementare.&lt;br /&gt;
&lt;br /&gt;
Un protocollo è semplicemente una lista di dichiarazioni di metodi, non allegate ad una definizione di classe. Per esempio, questi metodi che riportano azioni dell&#39;utente sul mouse, potrebbero essere raggruppati in un protocollo:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (void)mouseDown:(NSEvent *)theEvent;&lt;br /&gt;
&lt;br /&gt;
- (void)mouseDragged:(NSEvent *)theEvent;&lt;br /&gt;
&lt;br /&gt;
- (void)mouseUp:(NSEvent *)theEvent;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Ogni classe che vuole rispondere ad eventi del mouse dovrebbe adottare il protocollo e implementare i suoi metodi.&lt;br /&gt;
&lt;br /&gt;
I protocolli liberano le dichiarazioni dei metodi dalla dipendenza dalla gerarchia di classe, così che possono essere usate in modi in cui classi e categorie non possono. I protocolli elencano metodi che sono (o possono essere) implementati da qualche parte, ma l&#39;identità della classe che li implementa non è di interesse. Cosa è di interesse o meno è una particolare classe conforme al protocollo - se ha implementato dei metodi che il protocollo dichiara. Così gli oggetti possono essere raggruppati in tipi, non solo su basi di somiglianza dovute al fatto che ereditano dalla stessa classe, ma anche sulla base della loro somiglianza in conformazione allo stesso protocollo. Le classi in rami non collegati della gerarchia ereditaria, potrebbero essere tipate ugualmente perché sono conformi allo stesso protocollo.&lt;br /&gt;
&lt;br /&gt;
I protocolli possono giocare un ruolo significante nella progettazione OO, specialmente quando un progetto è diviso tra più implementatori o se incorpora oggetti sviluppati in altri progetti. Il software Cocoa usa pesantemente i protocolli per supportare la comunicazione tra i processi attraverso i messaggi Objective-C.&lt;br /&gt;
&lt;br /&gt;
Comunque, un programma Objective-C non ha bisogno di usare protocolli. A differenza della definizione di classi e le espressioni di messaggi, sono opzionali. Alcuni frameworks Cocoa li usano; altri no. Dipende tutto dal compito attuale.&lt;/div&gt;&lt;h2&gt;Metodi per gli altri da implementare.&lt;/h2&gt;&lt;div&gt;Se conosci la classe di un oggetto, puoi guardare la sua dichiarazione di interfaccia ( e le dichiarazioni delle interfacce delle classi da cui eredita) per trovare a quali messaggi risponde. Queste dichiarazioni annunciano i messaggi che ricevono. I protocolli forniscono anche un modo per fargli annunciare i messaggi che inviano.&lt;br /&gt;
&lt;br /&gt;
La comunicazione funziona in entrambi i modi; oggetti inviano messaggi così come lì ricevono. Ad esempio, un oggetto potrebbe delegare responsabilità per una certa operazione ad un altro oggetto, o potrebbe in occasione semplicemente aver bisogno di chiedere informazioni ad un altro oggetto. In alcuni casi, un oggetto potrebbe voler notificare ad altri oggetti le sue azioni così che loro possano prendere qualsiasi misura collaterale che potrebbe essere richiesta.&lt;br /&gt;
&lt;br /&gt;
Se sviluppi la classe di un sender e la classe di un receiver come parte dello stesso progetto (o se qualcun altro ti ha fornito il ricevitore e i suoi file interfaccia), questa comunicazione è facilmente coordinata. Il sender semplicemente importa il file interfaccia del receiver. Il file importato dichiara i selettori di metodo che il sender usa nei messaggi che invia.&lt;br /&gt;
&lt;br /&gt;
Comunque, se sviluppi un oggetto che invia messaggi a oggetti che non sono definiti - oggetti che stai lasciando agli altri da implementare - non vuoi avere il file di interfaccia del ricevente. Vi serve un altro modo di dichiarare i metodi che usate nei messaggi ma che non implementate. Un protocollo serve a questo scopo. Informa il compilatore riguardo ai metodi che la classe usa informa anche gli altri implementatori dei metodi che hanno bisogno di definire per avere i loro oggetti che lavorano con i tuoi. &lt;br /&gt;
&lt;br /&gt;
Supponiamo, ad esempio, che sviluppi un oggetto che chiede l&#39;assistenza di un altro oggetto inviandogli il messaggio helpOut: ed altri messaggi. Fornisci una variabile di istanza assistant per memorizzare l&#39;outlet per questi messaggi e definire un metodo compagno per impostare la variabile di istanza. Questo metodo permette agli altri oggetti di registrarsi come potenziali destinatari per i messaggi del tuo oggetto:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- setAssistant:anObject&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
assistant = anObject;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Allora, ogni volta che un messaggio sta per essere inviato ad assistant, è fatto un controllo per accertarsi che il ricevente implementi un metodo che possa rispondere:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (BOOL)doWork&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
if ( [assistant respondsToSelector:@selector(helpOut:)] ) {&lt;br /&gt;
&lt;br /&gt;
[assistant helpOut:self];&lt;br /&gt;
&lt;br /&gt;
return YES;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return NO;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Dato che, quando hai scritto questo codice, non potevi sapere che tipo di oggetti avrebbero potuto registrarsi come assistant, puoi solo dichiarare un protocollo per il metodo helpOut:; non puoi importare il file interfaccia della classe che lo implementa.&lt;/div&gt;&lt;h2&gt;Dichiarare Interfacce per Oggetti Anonimi&lt;/h2&gt;&lt;div&gt;Un protocollo può essere usato per dichiarare i metodi di un oggetto anonimo, un oggetto di classe sconosciuta. Un oggetto anonimo può rappresentare un servizio o gestire un insieme limitato di funzioni, specialmente dove serve un solo grande oggetto della sua classe. (Oggetti che giocano un ruolo fondamentale nel definire l&#39;architettura di un&#39;applicazione e oggetti che devi inizializzare prima di usare non sono buoni candidati per l&#39;anonimità).&lt;br /&gt;
&lt;br /&gt;
Gli oggetti non sono anonimi al loro sviluppatore, ovviamente, ma sono anonimi quando lo sviluppatore fornisce loro a qualcun altro. Ad esempio, considera le seguenti situazioni:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Qualcuno che fornisce un framework o una suite di oggetti ad altri da usare può includere oggetti che non sono identificati da un nome di classe o un file interfaccia. Mancando nome e interfaccia di classe, gli utenti non hanno modo di creare istanze della classe. Invece, il fornitore deve fornire un&#39;istanza pronta fatta. Tipicamente, un metodo in un&#39;altra classe restituisce un oggetto usabile:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codice&quot;&gt;id formatter = [receiver formattingService]; &lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt; L&#39;oggetto restituito dal metodo è un oggetto senza un&#39;identità di classe, almeno non uno dei fornitori è disposto a rivelare. Affinchè sia utile, il fornitore deve voler identificare almeno alcuni dei messaggi a cui esso può rispondere. Questo è fatto associando l&#39;oggetto con una lista di metodi dichiarati in un protocollo.&lt;/li&gt;
&lt;li&gt;Puoi inviare messaggi Objective-C a oggetti remoti - oggetti in altre applicazioni. Ogni applicazione ha la sua propria struttura, classi e logica interna. Ma non ti serve sapere come un&#39;altra applicazione funziona o con cosa i suoi componenti stanno comunicando.  Da straniero, tutto quello che devi sapere è quali messaggi puoi inviare (il protocollo) e dove inviarli (il ricevente). Un&#39;applicazione che pubblica uno dei suoi oggetti come potenziale ricevente di messaggi remoti, deve anche pubblicare un protocollo che dichiara i metodi che l&#39;oggetto userà per rispondere a quei messaggi. Non deve rivelare nient&#39;altro che l&#39;oggetto. L&#39;applicazione che invia non ha bisogno di conoscere la classe dell&#39;oggetto o usare la classe nel suo proprio design Tutto ciò che gli serve è il protocollo.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;I protocolli rendono possibili gli oggetti anonimi. Senza un protocollo, non ci sarebbe modo di dichiarare un&#39;interfaccia a un oggetto senza identificare la sua classe.&lt;/div&gt;&lt;div&gt;&lt;b&gt;Nota:&lt;/b&gt; anche se il fornitore di un oggetto anonimo non rivela la sua classe, l&#39;oggetto stesso si rivela a runtime. Un messaggio di classe restituisce la classe dell&#39;oggetto anonimo. Comunque, c&#39;è solitamente poco punto nel cercare queste informazioni extra; L&#39;informazione nel protocollo è sufficiente.&lt;/div&gt;&lt;h2&gt;Somiglianze Non-Gerarchiche&lt;/h2&gt;&lt;div&gt;Se più di una classe implementasse un insieme di metodi, quelle classi sarebbero spesso raggruppate sotto una classe astratta che dichiara i metodi che hanno in comune. Ogni sottoclasse potrebbe re-implementare i metodi a modo proprio, ma la gerarchia ereditaria e la dichiarazione in comune nella classe astratta cattura la somiglianza essenziale tra le sottoclassi.&lt;br /&gt;
Comunque, a volte non è possibile raggruppare metodi in comune in una classe astratta. Le classi non correlate in molti aspetti, che non potrebbero tuttavia aver bisogno di implementare alcuni metodi simili. Questa somiglianza singolare potrebbe non giustificare una relazione gerarchica. Ad esempio, potresti volere aggiungere un supporto per creare una rappresentazione XML degli oggetti nella tua applicazione e per inizializzare oggetti da una rappresentazione XML:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (NSXMLElement *)XMLRepresentation;&lt;br /&gt;
&lt;br /&gt;
- initFromXMLRepresentation:(NSXMLElement *)xmlString;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Questi metodi potrebbero essere raggruppati in un protocollo e le somiglianze tra le classi che lo implementano stimate per annotare che sono tutte conformi allo stesso protocollo.&lt;br /&gt;
&lt;br /&gt;
Gli oggetti possono essere tipati a seconda delle somiglianze (i protocolli a cui sono conformi), piuttosto che a seconda della loro classe. Ad esempio, un&#39;istanza di NSMatrix deve comunicare con gli oggetti che rappresentano le sue celle. La matrice potrebbe richiedere che ognuno di questi oggetti sia un tipo di NSCell (una classe basata su tipo) e affidarsi al fatto che tutti gli oggetti che eredita dalla classe NSCell hanno metodi che hanno bisogno di rispondere a messaggi di NSMatrix. Alternativamente, l&#39;oggetto NSMatrix potrebbe richiedere che oggetti rappresentanti celle abbiano metodi che possono a rispondere a un particolare insieme di messaggi (un tipo basato su protocollo). In questo caso, l&#39;oggetto NSMatrix non si preoccuperebbe di a quale classe appartiene un oggetto cella, appena ha implementato i metodi.&lt;/div&gt;&lt;h2&gt;Protocolli Formali&lt;/h2&gt;&lt;div&gt;Il linguaggio Objective-C fornisce un modo di dichiarare formalmente una lista di metodi come un protocollo. I protocolli formali sono supportati dal linguaggio e dal sistema di runtime. Ad esempio, il compilatore può controllare i tipi basati su protocolli, e gli oggetti possono introspezionare a runtime per riportare se sono o non sono conformi a un protocollo. &lt;/div&gt;&lt;h2&gt;Dichiarare un Protocollo&lt;/h2&gt;&lt;div&gt;I protocolli formali si dichiarano con la direttiva @protocol :&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@protocol ProtocolName&lt;br /&gt;
&lt;br /&gt;
method declarations&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Ad esempio, puoi dichiarare un protocollo di rappresentazione XML in questo modo:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@protocol MyXMLSupport&lt;br /&gt;
&lt;br /&gt;
- initFromXMLRepresentation:(NSXMLElement *)XMLElement;&lt;br /&gt;
&lt;br /&gt;
- (NSXMLElement *)XMLRepresentation;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Diversamente dai nomi di classi, i nomi dei protocolli non hanno visibilità globale. Vivono nel loro proprio namespace.&lt;/div&gt;&lt;h2&gt;Metodi di Protocolli Opzionali&lt;/h2&gt;&lt;div&gt;I metodi dei protocolli possono essere segnati come opzionali usando la parola chiave @optional. La parola chiave @required, corrisponde a @optional e denota formalmente la semantica del comportamento di default. Puoi usare @optional e @required per partizionare il tuo protocollo in sezioni. Se non specifichi alcuna parola chiave, è richiesto @required.&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@protocol MyProtocol&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- (void)requiredMethod;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@optional&lt;br /&gt;
&lt;br /&gt;
- (void)anOptionalMethod;&lt;br /&gt;
&lt;br /&gt;
- (void)anotherOptionalMethod;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@required&lt;br /&gt;
&lt;br /&gt;
- (void)anotherRequiredMethod;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;b&gt;Nota:&lt;/b&gt; In Mac OS X v10.5, i protocolli potrebbero non includere le proprietà dichiarate opzionali. Questo vincolo è rimosso da Mac OS X v10.6 in poi.&lt;/div&gt;&lt;h2&gt;Protocolli Informali&lt;/h2&gt;&lt;div&gt;In aggiunta ai protocolli formali, puoi anche definire un protocollo informale raggruppando i metodi in dichiarazioni di categoria:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface NSObject ( MyXMLSupport )&lt;br /&gt;
&lt;br /&gt;
- initFromXMLRepresentation:(NSXMLElement *)XMLElement;&lt;br /&gt;
&lt;br /&gt;
- (NSXMLElement *)XMLRepresentation;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;I protocolli informali sono tipicamente dichiarati come categorie della classe NSObject, dato che associano largamente i nomi dei metodi con qualunque classe che eredita da NSObject. Dato che tutte le classi ereditano dalla classe radice, i metodi non sono ristretti ad alcuna parte della gerarchia. (Potrebbe anche essere possibile dichiarare un protocollo informale come categoria di un&#39;altra classe per limitarlo a un certo ramo della gerarchia, ma ci sono poche ragioni per farlo).&lt;br /&gt;
&lt;br /&gt;
Una volta usato per dichiarare un protocollo, un&#39;interfaccia di categoria non ha un&#39;implementazione corrispondente. Invece, le classi che implementano il protocollo dichiarano ancora i metodi nei loro propri files di interfaccia e li definiscono insieme con gli altri metodi nei loro files di implementazione. &lt;br /&gt;
&lt;br /&gt;
Un protocollo informale piega le regole delle dichiarazioni di categoria per elencare un gruppo di metodi ma non associarli ad alcuna classe o implementazione particolare.&lt;br /&gt;
&lt;br /&gt;
Per essere informali, i protocolli dichiarati nelle categorie non ricevono molto supporto dal linguaggio. Non ci sono controlli di tipo a tempo di compilazione e neanche un controllo a runtime per vedere se un oggetto è conforme al protocollo. Per ottenere questi benefici, dovete usare un protocollo formale. Un protocollo informale potrebbe essere utile quando tutti i metodi sono opzionali, come per un delegato, ma è tipicamente meglio usare un protocollo formale con i metodi opzionali.&lt;/div&gt;&lt;h2&gt;Oggetti dei Protocolli&lt;/h2&gt;&lt;div&gt;Proprio come le classi sono rappresentate a runtime dagli oggetti della classe e i metodi dai codici selettori, i protocolli formali sono rappresentati da una speciale istanza-tipo di dati della classe Protocol. Il codice sorgente che si occupa del protocollo deve riferirsi all&#39;oggetto di Protocol.&lt;br /&gt;
&lt;br /&gt;
In molti modi, i protocolli sono simili alle definizioni di classe. Entrambi dichiarano metodi, e a runtime entrambi sono rappresentati da oggetti - classi da oggetti Class e protocolli da oggetti Protocol. Come gli oggetti di classe, gli oggetti di protocollo sono creati automaticamente dalle definizioni e le dichiarazioni trovate nel codice sorgente e sono usati dal sistema di runtime. Non sono allocati e inizializzati in codice sorgente programma.&lt;br /&gt;
&lt;br /&gt;
Il codice sorgente può riferirsi a un oggetto protocollo usando la direttiva @protocol( ) - la stessa direttiva che dichiara un protocollo, tranne che qui ha un insieme di parentesi tonde. Le parentesi racchiudono il nome del protocollo:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Protocol *myXMLSupportProtocol = @protocol(MyXMLSupport);&lt;/div&gt;&lt;div&gt;Questo è l&#39;unico modo per il codice sorgente di evocare un oggetto Protocol. Diversamente da un nome di classe, un nome di protocollo non designa l&#39;oggetto - tranne dentro @protocol( ).&lt;br /&gt;
&lt;br /&gt;
Il compilatore crea un oggetto Protocol per ogni dichiarazione di protocollo che incontra, ma solo se il protocollo è anche:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Adottato da una classe, o&lt;/li&gt;
&lt;li&gt;Riferito a qualche punto nel codice sorgente (usando @protocol( ) )&lt;/li&gt;
&lt;/ul&gt;I protocolli che sono dichiarati ma non usati (tranne per il controllo dei tipi descritto sotto) non sono rappresentati da oggetti Protocol a runtime.&lt;/div&gt;&lt;h2&gt;Adottare un Protocollo&lt;/h2&gt;&lt;div&gt;Adottare un protocollo è simile in alcuni modi a dichiarare una superclasse. Entrambi i metodi definiscono alla classe. La dichiarazione di superclasse gli assegna i metodi ereditati; Il protocollo gli assegna metodi dichiarati nella lista del protocollo. Si dice che una classe adotta un protocollo formale se nella sua dichiarazione, elenca il protocollo tra parentesi angolari dopo il nome della superclasse:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface ClassName : ItsSuperclass &amp;lt; protocol list &amp;gt;&lt;/div&gt;&lt;div&gt;Le categorie adottano protocolli più o meno allo stesso modo:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface ClassName ( CategoryName ) &amp;lt; protocol list &amp;gt;&lt;/div&gt;&lt;div&gt;Una classe può adottare più di un protocollo; i nomi nella lista dei protocolli sono separati da virgole.&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface Formatter : NSObject &amp;lt; Formatting, Prettifying &amp;gt;&lt;/div&gt;&lt;div&gt;Una classe o categoria che adotta un protocollo deve implementare tutti i metodi richiesti che il protocollo dichiara, altrimenti il compilatore emetterà un warning La classe Formatter sopra, definirebbe tutti i metodi richiesti dichiarati nei due protocolli che adotta, in aggiunta a qualunque potrebbe dichiarare lui stesso.&lt;br /&gt;
&lt;br /&gt;
Una classe o categoria che adotta un protocollo deve importare il file header dove il protocollo è dichiarato. I metodi dichiarati nel protocollo adottato non sono dichiarati altrove nell&#39;interfaccia di classe o categoria.&lt;br /&gt;
&lt;br /&gt;
é possibile per una classe adottare semplicemente protocolli e dichiarare nessun altro metodo. Ad esempio, la seguente dichiarazione di classe adotta i protocolli Formatti e Prettyfying, ma di per se non dichiara variabili di istanza o metodi:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface Formatter : NSObject &amp;lt; Formatting, Prettifying &amp;gt;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Conformarsi a un Protocollo&lt;/h2&gt;&lt;div&gt;Si dice che una classe è conforme a un protocollo formale se adotta il protocollo o eredita da altre classi che lo adottano. Un&#39;istanza della classe è detta conforme allo stesso insieme di protocolli a cui è conforme la sua classe.&lt;br /&gt;
&lt;br /&gt;
Dato che una classe deve implementare tutti i metodi richiesti dichiarati nel protocollo che adotta, dicendo che una classe o un&#39;istanza è conforme a un protocollo è equivalente a dire che ha nel suo repertorio tutti i metodi che il protocollo dichiara.&lt;br /&gt;
&lt;br /&gt;
È possibile controllare se un oggetto è conforme ad un protocollo inviandogli il messaggio conformsToProtocol:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;if ( ! [receiver conformsToProtocol:@protocol(MyXMLSupport)]  ) {&lt;br /&gt;
&lt;br /&gt;
// Object does not conform to MyXMLSupport protocol&lt;br /&gt;
&lt;br /&gt;
// If you are expecting receiver to implement methods declared in the&lt;br /&gt;
&lt;br /&gt;
//  MyXMLSupport protocol, this is probably an error&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;(Nota che c&#39;è anche un metodo di classe con lo stesso nome —conformsToProtocol: .)&lt;br /&gt;
&lt;br /&gt;
Il test conformsToProtocol: è come il test respondsToSelector: per un singolo metodo, tranne che testa se un protocollo è stato adottato ( e presumibilmente tutti i metodi che dichiara sono implementati) piuttosto che solo se un particolare metodo è stato implementato. Poiché controlla tutti i metodi, conformsToProtocol: può essere più efficiente rispetto a respondsToSelector:.&lt;br /&gt;
&lt;br /&gt;
Il test conformsToProtocol: è anche come il test isKindOfClass:, tranne per il fatto che testa su un tipo basato su un protocollo piuttosto che su un tipo basato su gerarchia ereditaria.&lt;/div&gt;&lt;h2&gt;Controlli di Tipo&lt;/h2&gt;&lt;div&gt;Le dichiarazioni di tipo per gli oggetti possono essere estese per includere protocolli formali. I protocolli così offrono la possibilità di un altro livello di controllo di tipi da parte del compilatore, uno che è più astratto dato che non è legato ad una particolare implementazione.&lt;br /&gt;
In una dichiarazione di tipo, i nomi dei protocolli sono elencati tra parentesi angolari dopo il nome del tipo:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (id &lt;formatting&gt;)formattingService;&lt;br /&gt;
&lt;br /&gt;
id &lt;myxmlsupport&gt; anObject;&lt;br /&gt;
&lt;br /&gt;
&lt;/myxmlsupport&gt;&lt;/formatting&gt;&lt;/div&gt;&lt;div&gt;Proprio come la tipatura satica permette al compilatore di testare su un tipo basato su gerarchia di classi, questa sintassi permette al compilatore di testare su un tipo basato sulla conformità ad un protocollo.&lt;br /&gt;
&lt;br /&gt;
Ad esempio, se Formatter è una classe astratta, questa dichiarazione&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Formatter *anObject;&lt;/div&gt;&lt;div&gt;raggruppa tutti gli oggetti che ereditano da Formatter in un tipo, e permette al compilatore di controllare gli assegnamenti contro quel tipo.&lt;br /&gt;
&lt;br /&gt;
Analogamente, questa dichiarazione,&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;id &lt;formatting&gt; anObject;&lt;/formatting&gt;&lt;/div&gt;&lt;div&gt;raggruppa tutti gli oggetti conformi al protocollo Formatting in un tipo, senza tener conto della loro posizione nella gerarchia delle classi. Il compilatore può accertarsi che solo gli oggetti conformi al protocollo siano assegnati al tipo.&lt;br /&gt;
&lt;br /&gt;
In ogni caso, il tipo raggruppa oggetti simili - in ogni caso, perché condividono un&#39;eredità comune, o perché convergono ad un comune insieme di metodi. &lt;br /&gt;
&lt;br /&gt;
I due tipi possono essere combinati in una dichiarazione singola:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;Formatter &lt;formatting&gt; *anObject;&lt;/formatting&gt;&lt;/div&gt;&lt;div&gt;I protocolli non possono essere usati per tipare gli oggetti delle classi. Solo le istanze possono essere tipate staticamente ad un protocollo, proprio come ogni istanza può essere staticamente tipata ad una classe. (comunque, a runtime, sia le classi che le istanze risponderanno ai messaggi conformsToProtocol:). &lt;/div&gt;&lt;h2&gt;Protocolli all&#39;interno di Protocolli&lt;/h2&gt;&lt;div&gt;Un protocollo può incorporare altri protocolli usando la stessa sintassi che le classi usano per adottare un protocollo:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@protocol ProtocolName &amp;lt; protocol list &amp;gt;&lt;/div&gt;&lt;div&gt;Tutti i protocolli elencati tra le parentesi angolari sono considerati parte del protocollo ProtocolName. Ad esempio se il protocollo Paging incorpora il protocollo Formatting,&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@protocol Paging &amp;lt; Formatting &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;qualsiasi oggetto conforme al protocollo Paging è conforme anche a Formatting. Dichiarazione di tipi&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;id &lt;paging&gt; someObject;&lt;/paging&gt;&lt;/div&gt;&lt;div&gt;e messaggi conformsToProtocol: &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;if ( [anotherObject conformsToProtocol:@protocol(Paging)] )&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;hanno bisogno di menzionare solo il protocollo Paging per testare anche la conformità di Formatting.&lt;br /&gt;
&lt;br /&gt;
Quando una classe adotta un protocollo, deve implementare i metodi richiesti che il protocollo dichiara, come abbiamo detto prima. In aggiunta, deve conformarsi a qualunque protocollo che il protocollo adottato incorpora. Se un protocollo incorporato incorpora ancora altri protocolli, la classe deve anche conformarsi a loro. Una classe può conformarsi ad un protocollo incorporato tramite o uno o l&#39;altro di questi modi:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Implementando i metodi che il protocollo dichiara, o&lt;/li&gt;
&lt;li&gt;ereditando da una classe che adotta il protocollo ed implementa i metodi.&lt;/li&gt;
&lt;/ul&gt;Supponiamo, ad esempio, che la classe Pager adotti il protocollo Paging. Se Pager fosse una sottoclasse di NSObject,&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface Pager : NSObject &amp;lt; Paging &amp;gt;&lt;/div&gt;&lt;div&gt;dovrebbe implementare tutti i metodi di Paging, inclusi quelli dichiarati nel protocollo incorporato Formatting. Adotta il protocollo Formatting insieme con Paging.&lt;br /&gt;
&lt;br /&gt;
D&#39;altro lato, se Pager è una sottoclasse di Formatter (una classe che indipendentemente adotta il protocollo Formatting),&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@interface Pager : Formatter &amp;lt; Paging &amp;gt;&lt;/div&gt;&lt;div&gt;deve implementare adeguatamente tutti i metodi dichiarati nel protocollo Paging, ma non quelli dichiarati in Formatting. Pager eredita la conformità al protocollo Formatting da Formatter.&lt;br /&gt;
&lt;br /&gt;
Nota che una classe può essere conforme a un protocollo senza adottarlo formalmente, semplicemente implementando i metodi dichiarati nel protocollo.&lt;/div&gt;&lt;h2&gt;Referring to Other Protocols&lt;/h2&gt;&lt;div&gt;Quando lavorando su applicazioni complesse, occasionalmente vi troverete a scrivere codice che assomiglia a questo:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;#import &quot;B.h&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@protocol A&lt;br /&gt;
&lt;br /&gt;
- foo:(id &amp;lt;B&amp;gt;)anObject;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;dove il protocollo B è dichiarato così:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;#import &quot;A.h&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@protocol B&lt;br /&gt;
&lt;br /&gt;
- bar:(id &amp;lt;A&amp;gt;)anObject;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;In una tale situazione, risulta la circolarità e nessun file compilerà correttamente. Per rompere questo ciclo ricorsivo, devi usare la direttiva @protocol per fare un riferimento anticipato al protocollo richiesto invece di importare il file interfaccia dove è definito il protocollo. Il seguente codice illustra come potresti farlo:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;@protocol B;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@protocol A&lt;br /&gt;
&lt;br /&gt;
- foo:(id &amp;lt;B&amp;gt;)anObject;&lt;br /&gt;
&lt;br /&gt;
@end&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Nota che usando la direttiva @protocol in questa maniera semplicemente si informa il compilatore che &quot;B&quot; è un protocollo che sarà definito successivamente. Non importa il file interfaccia dove è definito il protocollo B. &lt;/div&gt;&lt;hr /&gt;&lt;h2&gt;Fine quinta parte&lt;/h2&gt;&lt;div&gt;E siamo alla fine del quinto articolo di questa Guida dedicato ai Protocolli del linguaggio di programmazione Objective-C. Spero col tempo di realizzare un&#39;utile manuale disponibile a tutti. Il prossimo post di questa guida, tratterà la dichiarazione e l&#39;implementazione di proprietà. Segnalatemi eventuali errori, o commentate l&#39;articolo se l&#39;avete trovato utile, anche per incentivarmi a continuare a pubblicare le mie traduzioni. Iscrivetevi ai feed del blog per essere sempre aggiornati automaticamente ogni volta che sono disponibili nuovi contenuti.&lt;/div&gt;&lt;/span&gt;&lt;!-- &lt;/EdIndex&gt; --&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt;&lt;br /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-8661705-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/04/guida-objective-c-in-italiano-parte-5-i.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-389511790892419567.post-9063658603775319778</guid><pubDate>Fri, 16 Apr 2010 15:31:00 +0000</pubDate><atom:updated>2010-04-16T17:48:34.676+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">allocazione oggetti Obj-C</category><category domain="http://www.blogger.com/atom/ns#">apple developer</category><category domain="http://www.blogger.com/atom/ns#">esempi di codice</category><category domain="http://www.blogger.com/atom/ns#">Guida</category><category domain="http://www.blogger.com/atom/ns#">inizializzare oggetti in Obj-C</category><category domain="http://www.blogger.com/atom/ns#">Manuale italiano</category><category domain="http://www.blogger.com/atom/ns#">Objective C</category><category domain="http://www.blogger.com/atom/ns#">programmare per iPhone e iPad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Guida Objective-C in Italiano - Allocare e Inizializzare Oggetti</title><description>&lt;!-- &lt;EdIndex&gt; --&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s1600/programmare_in_objective_c.jpg&quot; onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; id=&quot;BLOGGER_PHOTO_ID_5457734146463113762&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s400/programmare_in_objective_c.jpg&quot; style=&quot;cursor: hand; cursor: pointer; display: block; height: 100px; margin: 0px auto 10px; text-align: center; width: 250px;&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;Questo è il quarto articolo della serie Guida all&#39;Objective-C, finora abbiamo introdotto i concetti base del linguaggio quali, gli Oggetti, le Classi, e la definizione di Classi e Interfacce. L&#39;argomento trattato oggi è l&#39;allocazione e l&#39;inizializzazione degli Oggetti.&lt;br /&gt;
&lt;br /&gt;
Questo post è una traduzione in italiano della Guida all&#39;Objective C, presente sul sito developer.apple.com a questo &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html#//apple_ref/doc/uid/TP30001163-CH22-SW1&quot; title=&quot;Articolo originale in Inglese&quot;&gt;link&lt;/a&gt;. L&#39;Objective C è il linguaggio di programmazione per creare applicazioni per iPhone. Questa guida potrebbe interessare a tutti gli sviluppatori che vogliono imparare le basi di questo linguaggio che è il fondamento per programmare nuove applicazioni per Mac Os X, iPhone ed iPad.&lt;/div&gt;&lt;hr /&gt;&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;fullpost&quot;&gt;&lt;h2&gt;Allocare e Inizializzare Oggetti&lt;/h2&gt;&lt;div&gt;Ci vogliono due passi per creare un oggetto usando Objective-C. Bisogna:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Dinamicamente allocare memoria per il nuovo oggetto&lt;/li&gt;
&lt;li&gt;Inizializzare la nuova memoria allocata a valori appropriati&lt;/li&gt;
&lt;/ul&gt;Un oggetto non è pienamente funzionale finché entrambi i passi sono stati completati. Ogni passo è compiuto da un metodo separato ma si può anche fare tutto in una singola linea di codice:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;id anObject = [[Rectangle alloc] init];&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;Separare l&#39;allocazione dall&#39;inizializzazione vi da il controllo individuale su ogni passo in modo che ognuno può essere modificato indipendentemente dall&#39;altro. Le sezioni seguenti badano prima all&#39;allocazione e poi all&#39;inizializzazione, e discutono come sono controllate e modificate.&lt;br /&gt;
&lt;br /&gt;
In Objective-C, la memoria per nuovi oggetti è allocata usando metodi di classe definiti nella classe NSObject. NSObject definisce due metodi principali per questo scopo, alloc e allocWithZone:.&lt;br /&gt;
&lt;br /&gt;
Questi metodi allocano abbastanza memoria per tenere tutte le variabili di istanza per un oggetto che appartiene alla classe ricevente. Non hanno bisogno di essere sovrascritti e modificati in sottoclassi.&lt;br /&gt;
&lt;br /&gt;
I metodi alloc ed allocWithZone: inizializzano una variabile di istanza isa di un oggetto nuovamente allocato, in modo che punta alla classe dell&#39;oggetto (l&#39;oggetto della classe). Tutte le altre variabili di istanza sono impostate a 0 Di solito un oggetto ha bisogno di essere inizializzato più specificatamente prima di poter essere usato in modo sicuro.&lt;br /&gt;
&lt;br /&gt;
Questa inizializzazione è la responsabilità di metodi di istanza specifici di classe che, per convenzione, iniziano con l&#39;abbreviazione &quot;init&quot;. Se il metodo non prende argomenti, il nome del metodo è giusto queste quattro lettere &quot;init&quot;. Se prende argomenti, etichettare gli argomenti con il prefisso init. Ad esempio un oggetto NSView può essere inizializzato con un metodo initWithFrame:.&lt;br /&gt;
&lt;br /&gt;
Ogni classe che dichiara variabili di istanza dovrebbe fornire un metodo init per inizializzarle. La classe NSObject dichiara la variabile isa e definisce un metodo init. Comunque, dato che isa è inizializzata quando è allocata memoria per un oggetto, tutto il metodo init di NSObject, fa e restituisce self NSObject dichiara il metodo principale per stabilire la convenzione per i nomi descritta prima. &lt;/div&gt;&lt;h2&gt;L&#39;Oggetto Restituito&lt;/h2&gt;&lt;div&gt;Un metodo init normalmente inizializza le variabili di istanza del ricevente, poi le restituisce. é responsabilità del metodo restituire un oggetto che può essere usato senza errori.&lt;br /&gt;
&lt;br /&gt;
Comunque, in alcune classi, questa responsabilità può restituire un oggetto diverso dal ricevente. Per esempio, se una classe mantiene una lista di oggetti nominati, potrebbe fornire un metodo initWitnName: per inizializzare le nuove istanze. Se ci possono essere non più di un oggetto per nome, initWithName: potrebbe rifiutarsi di assegnare lo stesso nome a due oggetti. Quando chiesto di assegnare a una nuova istana, un nome già usato da un altro oggetto, potrebbe liberare la nuova istanza allocata e restituire l&#39;altro oggetto - così da assicurare l&#39;unicità del nome mentre allo stesso tempo fornire cosa era stato chiesto, un&#39;istanza con il nome richiesto.&lt;br /&gt;
&lt;br /&gt;
In pochi casi, potrebbe essere impossibile per un metodo init fare cosa gli viene chiesto di fare. Ad esempio, un metodo initFromFile: potrebbe prendere i data che gli servono da un file passato come argomento. Se il nome del file passato non corrisponde ad u file attuale, non sarebbe in grado di completare l&#39;inizializzazione. In casi come questo, il metodo init, potrebbe liberare il ricevente e restituire nil, indicando che l&#39;oggetto richiesto non può essere creato.&lt;br /&gt;
&lt;br /&gt;
Dato che un metodo init potrebbe restituire un oggetto diverso dal nuovo ricevente allocato, o anche restituire nil, è importante che i programmi usino il valore restituito dal metodo inizializzazione, non solo quelli ritornati da alloc o allocWithZone:. Il codice seguente è molto pericoloso, dato che ignora il valore di ritorno di init.&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;id anObject = [SomeClass alloc];&lt;br /&gt;
&lt;br /&gt;
[anObject init];&lt;br /&gt;
&lt;br /&gt;
[anObject someOtherMessage];&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Invece, per inizializzare in modo sicuro un oggetto, dovreste combinare messaggi di allocazione e inizializzazione in una linea di codice.&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;id anObject = [[SomeClass alloc] init];&lt;br /&gt;
&lt;br /&gt;
[anObject someOtherMessage];&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Se c&#39;è una possibilità che il metodo init possa restituire nil, allora dovresti controllare il valore restituito prima di procedere:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;id anObject = [[SomeClass alloc] init];&lt;br /&gt;
&lt;br /&gt;
if ( anObject )&lt;br /&gt;
&lt;br /&gt;
[anObject someOtherMessage];&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;h2&gt;Implementare un Inizializzatore&lt;/h2&gt;&lt;div&gt;Quando un nuovo oggetto è creato, tutti i bit di memoria (tranne per l&#39;isa) - e quindi i valori per tutte le variabili di istanza - sono impostati a 0. In alcune situazioni, questo potrebbe essere tutto ciò che ti serve quando un oggetto è inizializzato; in molte altre, vuoi fornire altri valori di default per una variabile di istanza di un oggetto,  o vuoi passare valori come argomenti all&#39;inizializzatore. In questi altri casi, ti servirà scrivere un inizializer personalizzato. In Objective-C, gli inizializzatori personalizzati sono soggetti a più vincoli e convenzioni rispetto alla maggior parte degli altri metodi.&lt;/div&gt;&lt;h2&gt;Vincoli e Convenzioni&lt;/h2&gt;&lt;div&gt;Ci sono molti vincoli e convenzioni che si applicano ai metodi inizializzatori e che non si applicano agli altri metodi:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Da convenzione, il nome di un inizializzatore personalizzato inizia con init. Esempi dal framework Foundation includono, initWithFormat:, initWithObjects:, e initWithObjectAndKeys:.&lt;/li&gt;
&lt;li&gt;Il tipo restituito di un metodo inizializzatore dovrebbe essere id. Il motivo di questo è che id da un&#39;indicazione che la classe ha uno scopo non considerato espressamente - che la classe è nonspecificata e il soggetto cambia, a seconda del contesto dell&#39;invocazione. Ad esempio, NSString fornisce un metodo initWithFormat:. Quando è inviato a un&#39;istanza di NSMutableString (una sottoclasse di NSString), il messaggio restituisce un&#39;istanza di NSMutableString, non di NSString.&lt;/li&gt;
&lt;li&gt;Nell&#39;implementazione di un inizializzatore personalizzato, dovete invocare per ultimo un inizializzatore designato. Gli inizializzatori designati saranno descritti in seguito. In breve, se stai implementando un nuovo inizializzatore designato, lui deve invocare l&#39;inizializzatore designato della superclasse. Se stai implementando in qualunque altro inizializzatore, lui dovrebbe invocare l&#39;inizializzatore designato della sua propria classe, o un altro del suo proprio inizializzatore che in ultimo invoca l&#39;inizializzatore designato. Da default (come con NSObject), l&#39;inizializzatore designato è init.&lt;/li&gt;
&lt;li&gt;Dovresti assegnare self al valore restituito dall&#39;inizializzatore. Questo perchè l&#39;inizializzatore potrebbe restituire un oggetto diverso dal ricevente originale.&lt;/li&gt;
&lt;li&gt;Se imposti il valore di una variabile di istanza, lo fai tipicamente usando un assegnamento diretto piuttosto che un metodo accessorio. Questo evita la possibilità di innescare effetti collaterati indesiderati negli accessori.&lt;/li&gt;
&lt;li&gt;Alla fine dell&#39;inizializzatore, dovete restituire self, ameno che l&#39;inizializzatore fallisce, nel qual caso restituirete nil. Gli inizializzatori falliti saranno discussi più in dettaglio in seguito.&lt;/li&gt;
&lt;/ul&gt;Il seguente esempio illustra l&#39;implementazione di un inizializzatore personalizzato per una classe che eredita da NSobject e ha una variabile di istanza creationDate, che rappresenta il momento quando un oggetto è stato creato:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (id)init {&lt;br /&gt;
&lt;br /&gt;
// Assign self to value returned by super&#39;s designated initializer&lt;br /&gt;
&lt;br /&gt;
// Designated initializer for NSObject is init&lt;br /&gt;
&lt;br /&gt;
if (self = [super init]) {&lt;br /&gt;
&lt;br /&gt;
creationDate = [[NSDate alloc] init];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return self;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;(Il motivo di usare il pattern if (self = [super init]) sarà discusso in seguito).&lt;br /&gt;
&lt;br /&gt;
Un inizializzatore non ha bisogno di fornire un argomento per ogni variabile. Per esempio, se una classe richiede che le sue istanze abbiano un nome e una sorgente dati, potrebbe fornire un metodo initWithName:fromURL:, ma impostare variabili di istanza non essenziali a valori arbitrari o permettere loro di avere valori nulli impostati di default. Potrebbe allora affidarsi a metodi come setEnabled:, setFriend:, e setDimensions: per modificare i valori di default dopo che la fase di inizializzazione è stata completata.&lt;br /&gt;
&lt;br /&gt;
L&#39;esempio succesivo illustra l&#39;implementazione di un inizializzatore personalizzato che prende un singolo argomento. In questo caso, la classe eredita da NSView. Mostra che puoi svolgere del lavoro prima di invocare l&#39;inizializzatore designato della superclasse.&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (id)initWithImage:(NSImage *)anImage {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Find the size for the new instance from the image&lt;br /&gt;
&lt;br /&gt;
NSSize size = anImage.size;&lt;br /&gt;
&lt;br /&gt;
NSRect frame = NSMakeRect(0.0, 0.0, size.width, size.height);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Assign self to value returned by super&#39;s designated initializer&lt;br /&gt;
&lt;br /&gt;
// Designated initializer for NSView is initWithFrame:&lt;br /&gt;
&lt;br /&gt;
if (self = [super initWithFrame:frame]) {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
image = [anImage retain];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return self;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Questo esempio non mostra cosa fare se ci sono problemi durante l&#39;inizializzazione.&lt;/div&gt;&lt;h2&gt;Gestire Fallimenti di inizializzazione&lt;/h2&gt;&lt;div&gt;In generale, se c&#39;è un problema durante un&#39;inizializzazione di un metodo, dovresti chiamare [self release] e restituire nil.&lt;br /&gt;
&lt;br /&gt;
Ci sono due conseguenze principali per questa politica:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Ogni oggetto, (che sia la tua propria classe, una sottoclasse, o un chiamante esterno) che riceve un nil da un metodo inizializzatore dovrebbe essere in grado di occuparsene. Nel caso spiacevole dove il chiamante ha stabilito una qualsiasi referenza esterna all&#39;oggetto prima della chiamata,questo include annullare qualsiasi connessione.&lt;/li&gt;
&lt;li&gt;Ti devi accertare che i metodi dealloc siano sicuri in presenza di oggetti parzialmente inizializzati.&lt;/li&gt;
&lt;/ul&gt;&lt;b&gt;Nota:&lt;/b&gt; puoi chiamare solo [self release] al punto di fallimento. Se ottieni nil dall&#39;invocazione dell&#39;inizializzatore della superclasse, non dovresti chiamare anche release. Dovresti semplicemente pulire ogni referenza impostata che non si occupa di deallocare e restituire nil. Questo è tipicamente gestito dal pattern di eseguire inizializzazioni dentro un blocco dipendente su un testo dei valori di ritorno dell&#39;inizializzatore della superclasse - come visto negli esempi precedenti:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (id)init {&lt;br /&gt;
&lt;br /&gt;
if (self = [super init]) {&lt;br /&gt;
&lt;br /&gt;
creationDate = [[NSDate alloc] init];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return self;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Il seguente esempio costruisce ciò che abbiamo mostrato in Vincoli e Convenzioni per mostrare come gestire valori inappropriati passati al paramtetro:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (id)initWithImage:(NSImage *)anImage {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (anImage == nil) {&lt;br /&gt;
&lt;br /&gt;
[self release];&lt;br /&gt;
&lt;br /&gt;
return nil;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Find the size for the new instance from the image&lt;br /&gt;
&lt;br /&gt;
NSSize size = anImage.size;&lt;br /&gt;
&lt;br /&gt;
NSRect frame = NSMakeRect(0.0, 0.0, size.width, size.height);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Assign self to value returned by super&#39;s designated initializer&lt;br /&gt;
&lt;br /&gt;
// Designated initializer for NSView is initWithFrame:&lt;br /&gt;
&lt;br /&gt;
if (self = [super initWithFrame:frame]) {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
image = [anImage retain];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return self;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;L&#39;esempio successivo illustra la miglior pratica dove, nel caso di un problema, c&#39;è la possibilità di restituire informazioni significative nella forma di oggetto NSError restituito da riferimento:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (id)initWithURL:(NSURL *)aURL error:(NSError **)errorPtr {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (self = [super init]) {&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NSData *data = [[NSData alloc] initWithContentsOfURL:aURL&lt;br /&gt;
&lt;br /&gt;
options:NSUncachedRead error:errorPtr];&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if (data == nil) {&lt;br /&gt;
&lt;br /&gt;
// In this case the error object is created in the NSData initializer&lt;br /&gt;
&lt;br /&gt;
[self release];&lt;br /&gt;
&lt;br /&gt;
return nil;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// implementation continues...&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Tipicamente non dovresti usare eccezioni per significare errori di questo tipo.&lt;/div&gt;&lt;h2&gt;Coordinare Classi&lt;/h2&gt;&lt;div&gt;I metodi init... che una classe definisce tipicamente inizializzano solo quelle variabili dichiarate in quella classe. Le variabili di istanza ereditate sono inizializzate inviando un messaggio a super per eseguire un metodo inizializzatore definito da qualche parte più su nella gerarchia ereditaria:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- (id)initWithName:(NSString *)string {&lt;br /&gt;
&lt;br /&gt;
if ( self = [super init] ) {&lt;br /&gt;
&lt;br /&gt;
name = [string copy];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return self;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Il messaggio a super collega insieme i metodi inizializzatori in tutte le classi ereditate. Dato che lui viene prima, assicura che le variabili della superclasse siano inizializzate prima di quelle dichiarate nelle sottoclassi. Per esempio, un oggetto Rectangle deve essere inizializzato come NSObnect, un Graphic, e una Shape prima di essere inizializzato come un Rectangle.&lt;br /&gt;
&lt;br /&gt;
La connessione tra il metodo initWithName:illustrato sopra e il metodo ereditato init che incorpora è illustrata nella Figura 3-1:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Figura 3-1&lt;/b&gt;  Incorporare un Metodo Inizializzatore Ereditato&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ1HUfz9VcK6Qm8v0mx-SMQDLak_O7ULoPPZG3-XFhJcElwq0RArc4-iRFqCrLTP_urGweWmKmwQWX4TCeTq23oxtuBuZevkNcp5KVFT_ycnGr1c5iUawpZbW6sZ_a2qrYFrS94lIrcyi1/s1600/initsimple.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ1HUfz9VcK6Qm8v0mx-SMQDLak_O7ULoPPZG3-XFhJcElwq0RArc4-iRFqCrLTP_urGweWmKmwQWX4TCeTq23oxtuBuZevkNcp5KVFT_ycnGr1c5iUawpZbW6sZ_a2qrYFrS94lIrcyi1/s320/initsimple.gif&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Una classe deve anche assicurarsi che tutti i metodi inizializzatori ereditati funzionino. Ad esempio, se la classe A definisce un metodo init e la sua sottoclasse B definisce un initWithName:,  come mostrato in figura 3-1, B deve anche accertarsi che un messaggio init inizializza con successo le istanze di B. Il modo più facile per farlo è sostituire il metodo ereditato init con una versione che invochi initWithName:, come segue:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- init {&lt;br /&gt;
&lt;br /&gt;
return [self initWithName:&quot;default&quot;];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Il metodo initWithName:, vorrebbe, in cambio, invocare il metodo ereditato come mostrato prima. La Figura 3-2 include la versione di B di init.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Figura 3-2&lt;/b&gt;  Coprire un modello di inizializzazione ereditato&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcvFMj7kH9CpIeHKxiILoXg0Kqh6kU6eZkv4LGQYqkt8lRA4ui2LxTKSxeUtdo7Xpx5Zfi3q7tUnXf3DH4bARPLx8ZaI6FS_ApB48v9_ckzkPok5eLSnchriwsgwMYM_fT3Y2SiRm1d9eD/s1600/inita_b.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcvFMj7kH9CpIeHKxiILoXg0Kqh6kU6eZkv4LGQYqkt8lRA4ui2LxTKSxeUtdo7Xpx5Zfi3q7tUnXf3DH4bARPLx8ZaI6FS_ApB48v9_ckzkPok5eLSnchriwsgwMYM_fT3Y2SiRm1d9eD/s320/inita_b.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Coprire un modello di inizializzazione ereditato, rende la classe che definisci più portabile alle altre applicazioni. Se lasci scoperto un metodo ereditato, qualcun altro potrebbe usarlo per produrre istanze per la tua classe inizializzate non correttamente.&lt;/div&gt;&lt;h2&gt;L&#39;Inizializzatore Designato&lt;/h2&gt;&lt;div&gt;Nell&#39;esempio dato nel paragrafo &quot;Coordinare Classi&quot;, initWithName: sarebbe il metodo inizializzatore designato per la sua classe (classe B). L&#39;inizializzatore designato è il metodo in ogni classe che garantisce che le variabili di istanza designate siano inizializzate (inviando un messaggio a super per eseguire un metodo ereditato). è anche il metodo che effettua la maggior parte del lavoro, e quello che altri metodi inizializzatori invocano nella stessa classe. è una convenzione di Cocoa che l&#39;inizializzatore designato sia sempre il metodo che permette la maggior libertà di determinare il carattere di una nuova istanza (solitamente questo è quello con più argomenti, ma non sempre).&lt;br /&gt;
&lt;br /&gt;
È importante conoscere l&#39;inizializzaore designato quando si definisce una sottoclasse. Ad esempio, supponiamo di definire una classe C, una sottoclasse di B, ed implementare un metodo initWithName:fromFile:. In aggiunta a questo metodo, dobbiamo anche accertarci che i metodi ereditati init ed initWithName: funzionino per le istanze di C. Questo può essere fatto coprendo initWithName: di B con una versione che invoca initWithName:fromFile:.&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- initWithName:(char *)string {&lt;br /&gt;
&lt;br /&gt;
return [self initWithName:string fromFile:NULL];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Per un istanza della classe C, il metodo init ereditato invoca questa nuova versione di initWithName: che invoca initWithName:fromFile:. La relazione tra questi metodi è mostrata in figura 3-3:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Figura 3-3&lt;/b&gt;  Coprire l&#39;inizializzatore designato&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLJw4gF7akHTDpD0FLsEpVA6QXRASwYPAUdbAfohNmsU-Xhj2ZKHfHqfiMd1RDOMx2ddbndce2qnXzOarIF_8vaE0lKpV2LONdKr0Y2s-IuD8KnQFvwFx_gx4WRUtkFdOOqnNkHltBgwDF/s1600/initb_c.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLJw4gF7akHTDpD0FLsEpVA6QXRASwYPAUdbAfohNmsU-Xhj2ZKHfHqfiMd1RDOMx2ddbndce2qnXzOarIF_8vaE0lKpV2LONdKr0Y2s-IuD8KnQFvwFx_gx4WRUtkFdOOqnNkHltBgwDF/s320/initb_c.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;Questa figura omette un dettaglio importante. Il metodo initWithName:fromFile:, essendo l&#39;inizializzatore designato per la classe C, invia un messaggio a super per invocare un metodo d&#39;inizializzazione ereditato. Ma quale dei metodi di B dovrebbe invocare, init o initWithName:? Non può invocare init, per due ragioni:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Circolarità risulterebbe (init invoca initWithName: di C, che invoca initWithName:fromFile:, che invoca dinuovo init).&lt;/li&gt;
&lt;li&gt;Non sarà ingrado di prendere vantaggio dall&#39;inizializzazione nella versione initWithName: di B:.&lt;/li&gt;
&lt;/ul&gt;Quindi, initWithName:fromFile: deve invocare initWithName::&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;- initWithName:(char *)string fromFile:(char *)pathname {&lt;br /&gt;
&lt;br /&gt;
if ( self = [super initWithName:string] )&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Principio Generale: l&#39;inizializzatore designato in una classe deve, tramite un messaggio a super, invocare l&#39;iizializzatore designato nella superclasse.&lt;br /&gt;
&lt;br /&gt;
Gli inizializzatori designati sono concatenati l&#39;un l&#39;altro tramite messaggi a super, mentre altri metodi di inizializzazione sono concatenati a inizializzatori designati tramite il messaggio self.&lt;br /&gt;
&lt;br /&gt;
Figura 3-4 mostra come tutti i metodi inizializzatori nelle classi A, B e C sono collegati. Messaggi a self sono mostrati sulla sinistra e i messaggi a super sulla destra.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;b&gt;Figura 3-4&lt;/b&gt;  Initialization Chain&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-1sYdTNqQJVN9PZvQ7RGbIu-8kYfJFwf5LL0CslE4KhkvtINdXc7fBXPzoLsIISALUmYkSxlsoG8N9Fl8ImHMIwtNWGFT9-FZnue-3WMM-t-iVfQci8l7MU8EiQIhMqv6A0SJQumrHXOB/s1600/initall.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-1sYdTNqQJVN9PZvQ7RGbIu-8kYfJFwf5LL0CslE4KhkvtINdXc7fBXPzoLsIISALUmYkSxlsoG8N9Fl8ImHMIwtNWGFT9-FZnue-3WMM-t-iVfQci8l7MU8EiQIhMqv6A0SJQumrHXOB/s320/initall.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
Nota che la versione init di B invia un messaggio a self per invocare il metodo initWithName. Quindi, quando il ricevente è un&#39;istanza della classe B, invoca la versione initWithName: di B, e quando il ricevente è un&#39;istanza della clase C, invoca la versione di C.&lt;/div&gt;&lt;h2&gt;Combinare Allocazione e Inizializzazione&lt;/h2&gt;&lt;div&gt;In Cocoa, alcune classi definiscono metodi di creazione che combinano i due passi di allocare e inizializzare per restituire nuove istanze della classe inizializzate. Questi metodi sono spesso chiamati come costruttori convenienti e tipicamente prendono la forma + nomeClasse. Ad esempio, NSStrin ha i seguenti metodi (tra gli altri): &lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;+ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc;&lt;br /&gt;
&lt;br /&gt;
+ (id)stringWithFormat:(NSString *)format, ...;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;In modo analogo, NSArray definisce i seguenti metodi di classe che combinano allocazione e inizializzazione:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;+ (id)array;&lt;br /&gt;
&lt;br /&gt;
+ (id)arrayWithObject:(id)anObject;&lt;br /&gt;
&lt;br /&gt;
+ (id)arrayWithObjects:(id)firstObj, ...;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Nota che il tipo restituito da questi metodi è id. Per lo stesso motivo dei metodi inizializzatori, come discusso precedentemente.&lt;br /&gt;
&lt;br /&gt;
I metodi che combinano allocazione ed inizializzazione sono particolarmente di valore se l&#39;allocazione deve in qualche modo essere informata dall&#39;inizializzazione. Per esempio, se i dati per l&#39;inizializzazione sono presi da un file, e il file potrebbe contenere abbastanza dati per inizializzare più di un oggetto, sarebbe impossibile conoscere quanti oggetti sono allcoati finchè il file è aperto. in questo caso, potresti implementare un metodo listFromFile: che prende il nome del file come un argomento.  Aprirebbe ilfile, vede quanti oggetti da allocare, e crea una lista di oggetti larga abbastanza da tenere tutti i nuovi oggetti. Allora allocherebbe ed inizializzerebbe gli oggetti dai dati nel file, mettendoli nella lista, e finalmente restituendo la lista.&lt;br /&gt;
&lt;br /&gt;
Ha senso anche combinare allocazione ed inizializzazione in un singolo metodo se vuoi evitare il passo di allocare alla cieca la memoria per un nuovo oggetto che potresti non usare. Come detto prima, un metodo init... potrebbe sostituire a volte un altro oggetto per il ricevente. Ad esempio, quando a initWithName: è passato un nome che è già preso, potrebbe liberare il ricevente e al suo posto restituire l&#39;oggetto a cui li nome era stato precedentemente assegnato. Questo significa, che un oggetto è allocato e liberato immediatamente senza mai essere usato.&lt;br /&gt;
&lt;br /&gt;
Se il codice che determina se il ricevente dovrebbe essere inizializzato è posto nel metodo che esegue l&#39;allocazione invece che dentro init..., puoi evitare il passo di allocare una nuova istanza quando non è necessaria.&lt;br /&gt;
&lt;br /&gt;
Nel seguente esempio, il metodo soloist assicura che non c&#39;è più di un&#39;istanza della classe Soloist. Esso alloca ed inizializza una singola istanza condivisa:&lt;/div&gt;&lt;div class=&quot;codice&quot;&gt;+ (Soloist *)soloist {&lt;br /&gt;
&lt;br /&gt;
static Soloist *instance = nil;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if ( instance == nil ) {&lt;br /&gt;
&lt;br /&gt;
instance = [[self alloc] init];&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
return instance;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Nota che in questo caso il tipo restituito è Soloist *. Dato che il metodo restituisce una singola istanza condivisa, la tipatura forte è appropriata - Non ci sono aspettative che questo metodo sarà sovrascritto.&lt;/div&gt;&lt;hr /&gt;&lt;h2&gt;Fine quarta parte&lt;/h2&gt;&lt;div&gt;Finisce così anche il quarto articolo di questa Guida dedicato all&#39;allocazione e inizializzzione di oggetti nel linguaggio di programmazione Objective-C. Spero col tempo di realizzare un&#39;utile manuale disponibile a tutti. Il prossimo post di questa guida, tratterà l&#39;uso di protocolli. Segnalatemi eventuali errori, o commentate l&#39;articolo se l&#39;avete trovato utile, anche per incentivarmi a continuare a pubblicare le mie traduzioni.&lt;/div&gt;&lt;br /&gt;
&lt;/span&gt;&lt;!-- &lt;/EdIndex&gt; --&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Grazie per esservi iscritti al Feed di emdief.blogspot.com&lt;/div&gt;</description><link>http://emdief.blogspot.com/2010/04/guida-objective-c-in-italiano-allocare.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhItl-8IeO_RpucDNwMOla6Fu3eTxS-FnoakdXlBmYaZxK7uDpRPIvBp0KW4M4YxtYTTo_ipwy1xSKyXIAC4D9fDwZjKLRfry5MMXWZ6nZzGHT3w5q13xbu-82NHiU0dlQjPFgXkaowt3hF/s72-c/programmare_in_objective_c.jpg" height="72" width="72"/><thr:total>1</thr:total></item></channel></rss>