﻿// JScript File


//
//------------------ARRAY------------------------------------------------------------
//

//Implementa due metodi classici ed utili sugli array 
/* ----------------------------------------------------------------------------------- 
------- Contains() ------------------------------------------------------------------- 
------- 
------- Metodo per l'oggetto Array, consente di verificare se un elemento è presente 
------- nell'array: 
------- 
------- found = array.Contains( obj ); 
------- found è TRUE se l'array contiene (almeno un) elemento OBJ. 
------- 
------- --- */ 
function Contains( obj ) 
{ 
   for ( i in this ) 
      if ( this[i] == obj ) 
         return true; 
   return false; 
}//Contains 
Array.prototype.Contains = Contains; 

/* ----------------------------------------------------------------------------------- 
------- Remove() ------------------------------------------------------------------- 
------- 
------- Metodo per l'oggetto Array, consente di rimuovere un elemento dall'array: 
------- 
------- array.Remove( obj ); 
------- Rimuove la prima occorrenza dell'elemento OBJ presente nell'array. 
------- 
------- --- */ 
function Remove( obj ) 
{ 
   for ( i in this ) 
      if ( this[i] == obj ) 
      { 
         this.splice( i, 1 ); 
         return; 
      } 
}//Remove 
Array.prototype.Remove = Remove; 

/* ----------------------------------------------------------------------------------- 
------- RemoveAll() ------------------------------------------------------------------- 
------- 
------- Metodo per l'oggetto Array, consente di rimuovere tutte le occorrenze di un 
------- determinato elemento dall'array: 
------- 
------- array.RemoveAll( obj ); 
------- Rimuove tutte le occorrenze dell'elemento OBJ presenti nell'array. 
------- 
------- --- */ 
function RemoveAll( obj ) 
{ 
   for ( i in this ) 
      if ( this[i] == obj ) 
         this.splice( i, 1 ); 
}//RemoveAll 
Array.prototype.RemoveAll = RemoveAll;  

