my code stock.com

Snippet options

Download: Download snippet as conjunto.java.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

package diccionario;
import java.util.ArrayList;
import java.util.Iterator;

public class Conjunto<T> /*implements ConjuntoI*/{
   ArrayList <T>conjunto;
   
public Conjunto(){
	conjunto = new ArrayList<T>();
}
   
   

@Override
public String toString() {
	return "Conjunto [conjunto=" + conjunto + "]";
}

public Integer tamano() {
	return conjunto.size();
}



public void agregar(T i) {
	if(!esta(i)){
		  this.conjunto.add(i);
	}

	
}

public void eliminar(T i){
	int e = conjunto.indexOf(i);
	System.out.println(e);
	conjunto.remove(e);
	
	
}


@Override
public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + ((conjunto == null) ? 0 : conjunto.hashCode());
	return result;
}



@Override
public boolean equals(Object obj) {
	if (this == obj)
		return true;
	if (obj == null)
		return false;
	if (getClass() != obj.getClass())
		return false;
	Conjunto other = (Conjunto) obj;
	if (conjunto == null) {
		if (other.conjunto != null)
			return false;
	} else if (!conjunto.equals(other.conjunto))
		return false;
	return true;
}



public T iesimo(Integer indice) {// indico la posicion devuelvo el elemento
	return conjunto.get(indice);
}



Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.