package ru.job4j.setHash;
import java.util.Arrays;

public class Container {

    SetHash[] container = new SetHash[10];
    private int index = 0;

    public SetHash[] ensureCapacity(SetHash[] source, int capacity) {
        return Arrays.copyOf(source, capacity);
    }

    public void add (SetHash setHash) {
        int result = 0;

        if (index > container.length - 1) {
            container = ensureCapacity(container, index + 10);
        }

        if ( container[0] != null ) {
            for ( int i = 0; i < container.length; i++ ) {
                if (container[i]!=null) {
                    if (container[i].getKey() == setHash.getKey() ) {
                        result = 1;
                        break;
                    }
                }
            }
        }

        if (result == 0) {
            container[index] = setHash;
            index++;
        }
    }

    public boolean contains(String value) {
        boolean result = false;
        for (int i = 0; i < container.length; i++) {
            if (container[i] != null) {
                if (container[i].getValue() == value) {
                    result = true;
                    break;
                }
            }
        }
        return result;
    }

    public boolean remove(String value) {
        boolean result = false;
        for (int i = 0; i < container.length; i++) {
            if (container[i] != null) {
                if (container[i].getValue() == value) {
                    container[i] = null;
                    result = true;
                }
            }
        }
        return result;
    }
}

@@ -327,25 +327,24 @@
 result = 0;%0A
-%0A
         if (
@@ -440,33 +440,32 @@
  10);%0A        %7D%0A
-%0A
         if ( con
@@ -461,363 +461,102 @@
    i
-f ( container%5B0%5D != null ) %7B%0A            for ( int i = 0; i %3C container.length; i++ ) %7B%0A                if (container%5Bi%5D!=null) %7B%0A                    if (container%5Bi%5D.getKey() == setHash.getKey() ) %7B%0A                        result = 1;%0A                        break;%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A%0A        if (result == 0
+nt cell = Math.abs(setHash.hashCode() %25 container.length);%0A        if (container%5Bcell%5D == null
 ) %7B%0A
@@ -577,21 +577,20 @@
 ntainer%5B
-index
+cell
 %5D = setH

task #998