All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.barrybecker4.game.twoplayer.go.board.elements.string.GoStringSet Maven / Gradle / Ivy

There is a newer version: 1.6
Show newest version
/** Copyright by Barry G. Becker, 2000-2011. Licensed under MIT License: http://www.opensource.org/licenses/MIT  */
package com.barrybecker4.game.twoplayer.go.board.elements.string;

import com.barrybecker4.game.twoplayer.go.board.elements.position.GoBoardPosition;

import java.util.LinkedHashSet;

/**
 *  A set of GoStrings.
 *
 *  @author Barry Becker
 */
public class GoStringSet extends LinkedHashSet {

    public GoStringSet() {}

    /**
     * Copy constructor.
     * @param set set of strings to initialize with
     */
    public GoStringSet(GoStringSet set) {
        super(set);
    }

    /**
     *
     * @param pos position
     * @return the string that contains pos if any. Null if none.
     */
    public IGoString findStringContainingPosition(GoBoardPosition pos) {
        for (IGoString str : this) {
            if (str.contains(pos)) {
                return str;
            }
        }
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy