001/* Copyright (C) 2013 TU Dortmund 002 * This file is part of AutomataLib, http://www.automatalib.net/. 003 * 004 * AutomataLib is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Lesser General Public 006 * License version 3.0 as published by the Free Software Foundation. 007 * 008 * AutomataLib is distributed in the hope that it will be useful, 009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 011 * Lesser General Public License for more details. 012 * 013 * You should have received a copy of the GNU Lesser General Public 014 * License along with AutomataLib; if not, see 015 * http://www.gnu.de/documents/lgpl.en.html. 016 */ 017package net.automatalib.commons.util.array; 018 019import java.util.Collection; 020 021/** 022 * Unified interface for (collection) classes that allow writing their contents to an array. 023 * The intended behavior differs from the standard Java {@link Collection#toArray(Object[])} method 024 * in the following way: 025 * - 026 * 027 * @author Malte Isberner <malte.isberner@gmail.com> 028 * 029 * @param <T> type class. This is a marker parameter that is not reflected in the signatures, 030 * but respected by the methods in {@link AWUtil}. 031 */ 032public interface ArrayWritable<T> { 033 /** 034 * Writes the contents of this container to an array. The behavior of calling this method 035 * should be equivalent to 036 * <code>System.arraycopy(this.toArray(), offset, array, tgtOfs, num);</code> 037 * 038 * @param offset how many elements of <i>this</i> container to skip. 039 * @param array the array in which to store the elements. 040 * @param tgtOfs the starting offset in the target array. 041 * @param num the maximum number of elements to copy. 042 */ 043 public void writeToArray(int offset, Object[] array, int tgtOfs, int num); 044 045 046 /** 047 * The size of this container. 048 */ 049 public int size(); 050}