text:
<?php
$TRANSLATIONS = array(
"Invalid value supplied for %s" => "%s-entzako baliogabea",
"Saved" => "Gordeta",
"test email settings" => "probatu eposta ezarpenak",
"If you received this email, the settings seem to be correct." => "Eposta hau jaso baduzu, zure ezarpenak egokiak direnaren seinale",
"A problem occurred while sending the e-mail. Please revisit your settings." => "Arazo bat gertatu da eposta bidaltzean. Berrikusi zure ezarpenak.",
"Email sent" => "Eposta bidalia",
"You need to set your user email before being able to send test emails." => "Epostaren erabiltzailea zehaztu behar duzu probako eposta bidali aurretik.",
"Send mode" => "Bidaltzeko modua",
"Encryption" => "Enkriptazioa",
"Authentication method" => "Autentifikazio metodoa",
"Unable to load list from App Store" => "Ezin izan da App Dendatik zerrenda kargatu",
"Authentication error" => "Autentifikazio errorea",
"Your full name has been changed." => "Zure izena aldatu egin da.",
"Unable to change full name" => "Ezin izan da izena aldatu",
"Group already exists" => "Taldea dagoeneko existitzenda",
"Unable to add group" => "Ezin izan da taldea gehitu",
"Files decrypted successfully" => "Fitxategiak ongi deskodetu dira.",
"Couldn't decrypt your files, please check your owncloud.log or ask your administrator" => "Ezin izan dira zure fitxategiak deskodetu, egiaztatu zure owncloud.log edo galdetu administratzaileari",
"Couldn't decrypt your files, check your password and try again" => "Ezin izan dira deskodetu zure fitxategiak, egiaztatu zure pasahitza eta saiatu berriz",
"Encryption keys deleted permanently" => "Enkriptatze gakoak behin betiko ezabatuak",
"Couldn't permanently delete your encryption keys, please check your owncloud.log or ask your administrator" => "Ezin izan dira zure enkriptatze gakoak behin betiko ezabatu, egiaztatu zure owncloud.log edo galdetu administratzaileari",
"Couldn't remove app." => "Ezin izan da aplikazioa ezabatu..",
"Email saved" => "Eposta gorde da",
"Invalid email" => "Baliogabeko eposta",
"Unable to delete group" => "Ezin izan da taldea ezabatu",
"Unable to delete user" => "Ezin izan da erabiltzailea ezabatu",
"Backups restored successfully" => "Babeskopiak ongi leheneratu dira",
"Couldn't restore your encryption keys, please check your owncloud.log or ask your administrator" => "Ezin izan dira zure enkriptatze gakoak leheneratu, egiaztatu zure owncloud.log edo galdetu administratzaileari",
"Language changed" => "Hizkuntza aldatuta",
"Invalid request" => "Baliogabeko eskaera",
"Admins can't remove themself from the admin group" => "Kudeatzaileak ezin du bere burua kendu kudeatzaile taldetik",
"Unable to add user to group %s" => "Ezin izan da erabiltzailea %s taldera gehitu",
"Unable to remove user from group %s" => "Ezin izan da erabiltzailea %s taldetik ezabatu",
"Couldn't update app." => "Ezin izan da aplikazioa eguneratu.",
"Wrong password" => "Pasahitz okerra",
"No user supplied" => "Ez da erabiltzailerik zehaztu",
"Please provide an admin recovery password, otherwise all user data will be lost" => "Mesedez eman berreskuratzeko administrazio  pasahitza, bestela erabiltzaile datu guztiak galduko dira",
"Wrong admin recovery password. Please check the password and try again." => "Administratzailearen berreskuratze pasahitza ez egokia. Mesedez egiaztatu pasahitza eta saiatu berriz.",
"Back-end doesn't support password change, but the users encryption key was successfully updated." => "Atzeko prozesuak ez du pasahitz aldaketa onartzen, baina erabiltzailearen enkriptatze gakoa ongi eguneratu da.",
"Unable to change password" => "Ezin izan da pasahitza aldatu",
"Sending..." => "Bidaltzen...",
"User Documentation" => "Erabiltzaile dokumentazioa",
"Admin Documentation" => "Administrazio dokumentazioa",
"Update to {appversion}" => "Eguneratu {appversion}-ra",
"Uninstall App" => "Desinstalatu aplikazioa",
"Disable" => "Ez-gaitu",
"Enable" => "Gaitu",
"Please wait...." => "Itxoin mesedez...",
"Error while disabling app" => "Erroea izan da aplikazioa desgaitzerakoan",
"Error while enabling app" => "Erroea izan da aplikazioa gaitzerakoan",
"Updating...." => "Eguneratzen...",
"Error while updating app" => "Errorea aplikazioa eguneratzen zen bitartean",
"Error" => "Errorea",
"Update" => "Eguneratu",
"Updated" => "Eguneratuta",
"Uninstalling ...." => "Desinstalatzen ...",
"Error while uninstalling app" => "Erroea izan da aplikazioa desinstalatzerakoan",
"Uninstall" => "Desinstalatu",
"Select a profile picture" => "Profilaren irudia aukeratu",
"Very weak password" => "Pasahitz oso ahula",
"Weak password" => "Pasahitz ahula",
"So-so password" => "Halamoduzko pasahitza",
"Good password" => "Pasahitz ona",
"Strong password" => "Pasahitz sendoa",
"Decrypting files... Please wait, this can take some time." => "Fitxategiak deskodetzen... Itxaron, bere denbora eskatzen du.",
"Delete encryption keys permanently." => "Ezabatu enkriptatze gakoak behin betiko",
"Restore encryption keys." => "Leheneratu enkriptatze gakoak",
"Unable to delete {objName}" => "Ezin izan da {objName} ezabatu",
"Error creating group" => "Errore bat izan da taldea sortzean",
"A valid group name must be provided" => "Baliozko talde izena eman behar da",
"deleted {groupName}" => "{groupName} ezbatuta",
"undo" => "desegin",
"Groups" => "Taldeak",
"Group Admin" => "Talde administradorea",
"Delete" => "Ezabatu",
"never" => "inoiz",
"deleted {userName}" => "{userName} ezabatuta",
"add group" => "gehitu taldea",
"A valid username must be provided" => "Baliozko erabiltzaile izena eman behar da",
"Error creating user" => "Errore bat egon da erabiltzailea sortzean",
"A valid password must be provided" => "Baliozko pasahitza eman behar da",
"Warning: Home directory for user \"{user}\" already exists" => "Abisua: \"{user}\" erabiltzailearen Home karpeta dagoeneko exisititzen da",
"__language_name__" => "Euskara",
"Everything (fatal issues, errors, warnings, info, debug)" => "Dena (arazo larriak, erroreak, abisuak, informazioa, arazketa)",
"Info, warnings, errors and fatal issues" => "Informazioa, abisuak, erroreak eta arazo larriak.",
"Warnings, errors and fatal issues" => "Abisuak, erroreak eta arazo larriak",
"Errors and fatal issues" => "Erroreak eta arazo larriak",
"Fatal issues only" => "Bakarrik arazo larriak",
"None" => "Ezer",
"Login" => "Saio hasiera",
"Plain" => "Arrunta",
"NT LAN Manager" => "NT LAN Manager",
"SSL" => "SSL",
"TLS" => "TLS",
"Security Warning" => "Segurtasun abisua",
"You are accessing %s via HTTP. We strongly suggest you configure your server to require using HTTPS instead." => "%s HTTP bidez erabiltzen ari zara. Aholkatzen dizugu zure zerbitzaria HTTPS erabil dezan.",
"Your data directory and your files are probably accessible from the internet. The .htaccess file is not working. We strongly suggest that you configure your webserver in a way that the data directory is no longer accessible or you move the data directory outside the webserver document root." => "Zure data karpeta eta zure fitxategiak internetetik zuzenean eskuragarri egon daitezke.  .htaccess fitxategia ez du bere lana egiten. Aholkatzen dizugu zure web zerbitzaria ongi konfiguratzea data karpeta eskuragarri ez izateko edo data karpeta web zerbitzariaren dokumentu errotik mugitzea.",
"Setup Warning" => "Konfiguratu abisuak",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Zure web zerbitzaria ez dago oraindik ongi konfiguratuta fitxategien sinkronizazioa egiteko, WebDAV interfazea ongi ez dagoela dirudi.",
"Please double check the installation guides." => "Mesedez birpasatu instalazio gidak.",
"PHP is apparently setup to strip inline doc blocks. This will make several core apps inaccessible." => "Badirudi PHP konfiguratuta dagoela lineako dokumentu blokeak aldatzeko. Honek zenbait oinarrizko aplikazio eskuraezin bihurtuko ditu.",
"This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator." => "Hau ziur aski cache/accelerator batek eragin du, hala nola Zend OPcache edo eAccelerator.",
"Database Performance Info" => "Database Performance informazioa",
"SQLite is used as database. For larger installations we recommend to change this. To migrate to another database use the command line tool: 'occ db:convert-type'" => "SQLite erabili da datu-base gisa. Instalazio handiagoetarako gomendatzen dugu aldatzea. Beste datu base batera migratzeko erabili komando-lerro tresna hau:  'occ db:convert-type'",
"Module 'fileinfo' missing" => "'fileinfo' modulua falta da",
"The PHP module 'fileinfo' is missing. We strongly recommend to enable this module to get best results with mime-type detection." => "PHP 'fileinfo' modulua falta da. Modulu hau gaitzea aholkatzen dizugu mime-type ezberdinak hobe detektatzeko.",
"Your PHP version is outdated" => "Zure PHP bertsioa zaharkituta dago",
"Your PHP version is outdated. We strongly recommend to update to 5.3.8 or newer because older versions are known to be broken. It is possible that this installation is not working correctly." => "Zure PHP bertsioa zaharkituta dago. Gure aholkua 5.3.8 edo bertsio berriago batera eguneratzea da, bertsio zaharragoak arazoak ematen baitituzte. Posible da instalazio honek ez funtzionatzea ongi.",
"Locale not working" => "Lokala ez dabil",
"System locale can not be set to a one which supports UTF-8." => "Eskualdeko ezarpena ezin da UTF-8 onartzen duen batera ezarri.",
"This means that there might be problems with certain characters in file names." => "Honek esan nahi du fitxategien izenetako karaktere batzuekin arazoak egon daitezkeela.",
"We strongly suggest to install the required packages on your system to support one of the following locales: %s." => "Biziki gomendatzen dizugu beharrezkoak diren paketea zure sisteman instalatzea honi euskarria eman ahal izateko: %s.",
"Internet connection not working" => "Interneteko konexioak ez du funtzionatzen",
"This server has no working internet connection. This means that some of the features like mounting of external storage, notifications about updates or installation of 3rd party apps don´t work. Accessing files from remote and sending of notification emails might also not work. We suggest to enable internet connection for this server if you want to have all features." => "Zerbitzari honen interneteko konexioa ez dabil. Honek esan nahi du kanpoko biltegiratze zerbitzuak, eguneraketen informazioa edo bestelako aplikazioen instalazioa bezalako programek ez dutela funtzionatuko. Urrunetik fitxategiak eskuratzea eta e-postak bidaltzea ere ezinezkoa izan daiteke. onwCloud-en aukera guztiak erabili ahal izateko zerbitzari honetan interneteko konexioa gaitzea aholkatzen dizugu.",
"Cron" => "Cron",
"Last cron was executed at %s." => "Azken cron-a  %s-etan exekutatu da",
"Last cron was executed at %s. This is more than an hour ago, something seems wrong." => "Azken cron-a %s-etan exekutatu da. Ordu bat baino gehiago pasa da, zerbait gaizki dabilela dirudi.",
"Cron was not executed yet!" => "Cron-a oraindik ez da exekutatu!",
"Execute one task with each page loaded" => "Exekutatu zeregin bat orri karga bakoitzean",
"cron.php is registered at a webcron service to call cron.php every 15 minutes over http." => "cron.php webcron zerbitzu batean erregistratua dago cron.php  15 minuturo http bidez deitzeko.",
"Use system's cron service to call the cron.php file every 15 minutes." => "Erabili sistemaren cron zerbitzua cron.php fitxategia 15 minuturo deitzeko.",
"Sharing" => "Partekatzea",
"Allow apps to use the Share API" => "Baimendu aplikazioak partekatzeko APIa erabiltzeko",
"Allow users to share via link" => "Baimendu erabiltzaileak esteken bidez partekatzea",
"Enforce password protection" => "Betearazi pasahitzaren babesa",
"Allow public uploads" => "Baimendu igoera publikoak",
"Set default expiration date" => "Ezarri muga data lehenetsia",
"Expire after " => "Iraungia honen ondoren",
"days" => "egun",
"Enforce expiration date" => "Muga data betearazi",
"Allow resharing" => "Baimendu birpartekatzea",
"Restrict users to only share with users in their groups" => "Mugatu partekatzeak taldeko erabiltzaileetara",
"Allow users to send mail notification for shared files" => "Baimendu erabiltzaileak epostako jakinarazpenak bidaltzen partekatutako fitxategientzat",
"Exclude groups from sharing" => "Baztertu taldeak partekatzean",
"These groups will still be able to receive shares, but not to initiate them." => "Talde hauek oraindik jaso ahal izango dute partekatzeak, baina ezingo dute partekatu",
"Security" => "Segurtasuna",
"Enforce HTTPS" => "Behartu HTTPS",
"Forces the clients to connect to %s via an encrypted connection." => "Bezeroak %s-ra konexio enkriptatu baten bidez konektatzera behartzen ditu.",
"Please connect to your %s via HTTPS to enable or disable the SSL enforcement." => "Mesedez konektatu zure %s-ra HTTPS bidez SSL zehaztapenak aldatzeko.",
"Email Server" => "Eposta zerbitzaria",
"This is used for sending out notifications." => "Hau jakinarazpenak bidaltzeko erabiltzen da.",
"From address" => "Helbidetik",
"mail" => "posta",
"Authentication required" => "Autentikazioa beharrezkoa",
"Server address" => "Zerbitzariaren helbidea",
"Port" => "Portua",
"Credentials" => "Kredentzialak",
"SMTP Username" => "SMTP erabiltzaile-izena",
"SMTP Password" => "SMTP pasahitza",
"Test email settings" => "Probatu eposta ezarpenak",
"Send email" => "Bidali eposta",
"Log" => "Log",
"Log level" => "Erregistro maila",
"More" => "Gehiago",
"Less" => "Gutxiago",
"Version" => "Bertsioa",
"Developed by the ownCloud community, the source code is licensed under the AGPL." => "ownCloud komunitateak garatuta, itubruru kodeaAGPL lizentziarekin banatzen da.",
"Add your App" => "Gehitu zure aplikazioa",
"More Apps" => "Aplikazio gehiago",
"Select an App" => "Aukeratu aplikazio bat",
"Documentation:" => "Dokumentazioa:",
"See application page at apps.owncloud.com" => "Ikusi aplikazioaren orria apps.owncloud.com orrian",
"See application website" => "Ikusi aplikazioaren webgunea",
"-licensed by " => "-lizentziatua ",
"Enable only for specific groups" => "Baimendu bakarri talde espezifikoetarako",
"All" => "Denak",
"Administrator Documentation" => "Administratzaile dokumentazioa",
"Online Documentation" => "Online dokumentazioa",
"Forum" => "Foroa",
"Bugtracker" => "Bugtracker",
"Commercial Support" => "Babes komertziala",
"Get the apps to sync your files" => "Lortu aplikazioak zure fitxategiak sinkronizatzeko",
"Show First Run Wizard again" => "Erakutsi berriz Lehenengo Aldiko Morroia",
"You have used %s of the available %s" => "Dagoeneko %s erabili duzu eskuragarri duzun %setatik",
"Password" => "Pasahitza",
"Your password was changed" => "Zure pasahitza aldatu da",
"Unable to change your password" => "Ezin izan da zure pasahitza aldatu",
"Current password" => "Uneko pasahitza",
"New password" => "Pasahitz berria",
"Change password" => "Aldatu pasahitza",
"Full Name" => "Izena",
"Email" => "E-posta",
"Your email address" => "Zure e-posta",
"Fill in an email address to enable password recovery and receive notifications" => "Bete ezazu eposta helbide bat pasahitza berreskuratzeko eta jakinarazpenak jasotzeko",
"Profile picture" => "Profilaren irudia",
"Upload new" => "Igo berria",
"Select new from Files" => "Hautatu berria Fitxategietatik",
"Remove image" => "Irudia ezabatu",
"Either png or jpg. Ideally square but you will be able to crop it." => "png edo jpg. Hobe karratua baina mozteko aukera izango duzu.",
"Your avatar is provided by your original account." => "Zure jatorrizko kontuak ezarri du zure avatar.",
"Cancel" => "Ezeztatu",
"Choose as profile image" => "Profil irudi bezala aukeratu",
"Language" => "Hizkuntza",
"Help translate" => "Lagundu itzultzen",
"The encryption app is no longer enabled, please decrypt all your files" => "Enkriptazio aplikazioa ez dago jada gaiturik, mesedez desenkriptatu zure fitxategi guztiak.",
"Log-in password" => "Saioa hasteko pasahitza",
"Decrypt all Files" => "Desenkripattu fitxategi guztiak",
"Your encryption keys are moved to a backup location. If something went wrong you can restore the keys. Only delete them permanently if you are sure that all files are decrypted correctly." => "Zure enkriptatze gakoak babeskopiara eraman dira. Zerbait gaizki ateratzen bada berreskura ditzakezu giltzak. Behin betirako ezabatu bakarrik ziur bazaude fitxategi guztiak ongi deskodetu badira.",
"Restore Encryption Keys" => "Lehenera itzazu enkriptatze gakoak.",
"Delete Encryption Keys" => "Ezabatu enkriptatze gakoak",
"Login Name" => "Sarrera Izena",
"Create" => "Sortu",
"Admin Recovery Password" => "Administratzailearen pasahitza berreskuratzea",
"Enter the recovery password in order to recover the users files during password change" => "Berreskuratze pasahitza idatzi pasahitz aldaketan erabiltzaileen fitxategiak berreskuratzeko",
"Search Users and Groups" => "Bilatu erabiltzaileak eta taldeak",
"Add Group" => "Gehitu taldea",
"Group" => "Taldea",
"Everyone" => "Edonor",
"Admins" => "Administratzaileak",
"Default Quota" => "Kuota lehentsia",
"Please enter storage quota (ex: \"512 MB\" or \"12 GB\")" => "Mesedez sartu biltegiratze kouta (adb: \"512 MB\" edo \"12 GB\")",
"Unlimited" => "Mugarik gabe",
"Other" => "Bestelakoa",
"Username" => "Erabiltzaile izena",
"Quota" => "Kuota",
"Storage Location" => "Biltegiaren kokapena",
"Last Login" => "Azken saio hasiera",
"change full name" => "aldatu izena",
"set new password" => "ezarri pasahitz berria",
"Default" => "Lehenetsia"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";


text:
package org.assertj.db.api.assertions.impl;

import org.assertj.core.api.Assertions;
import org.assertj.core.api.WritableAssertionInfo;
import org.assertj.db.api.TableAssert;
import org.assertj.db.common.AbstractTest;
import org.assertj.db.type.Table;
import org.assertj.db.type.Value;
import org.junit.Test;

import java.sql.Time;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.assertj.db.api.Assertions.assertThat;
import static org.junit.Assert.fail;

/**
 * Tests on {@link AssertionsOnColumnType} class :
 * {@link AssertionsOnColumnType#isTime(org.assertj.db.api.AbstractAssert, org.assertj.core.api.WritableAssertionInfo, java.util.List, boolean)} method.
 *
 * @author Régis Pouiller
 *
 */
public class AssertionsOnColumnType_IsTime_Test extends AbstractTest {

  /**
   * This method tests the {@code isTime} assertion method.
   */
  @Test
  public void test_is_time() throws Exception {
    WritableAssertionInfo info = new WritableAssertionInfo();
    Table table = new Table();
    TableAssert tableAssert = assertThat(table);
    List<Value> list = new ArrayList<>(Arrays.asList(getValue(null, Time.valueOf("09:01:00")),
                                                     getValue(null, Time.valueOf("09:01:00"))));
    TableAssert tableAssert2 = AssertionsOnColumnType.isTime(tableAssert, info, list, false);
    Assertions.assertThat(tableAssert2).isSameAs(tableAssert);
    list = new ArrayList<>(Arrays.asList(getValue(null, Time.valueOf("09:01:00")),
                                         getValue(null, Time.valueOf("09:01:00"))));
    tableAssert2 = AssertionsOnColumnType.isTime(tableAssert, info, list, true);
    Assertions.assertThat(tableAssert2).isSameAs(tableAssert);
    list = new ArrayList<>(Arrays.asList(getValue(null, null),
                                         getValue(null, Time.valueOf("09:01:00"))));
    tableAssert2 = AssertionsOnColumnType.isTime(tableAssert, info, list, true);
    Assertions.assertThat(tableAssert2).isSameAs(tableAssert);
  }

  /**
   * This method should fail because the value is not a time.
   */
  @Test
  public void should_fail_because_value_is_not_a_time() throws Exception {
    WritableAssertionInfo info = new WritableAssertionInfo();
    info.description("description");
    Table table = new Table();
    TableAssert tableAssert = assertThat(table);
    try {
      List<Value> list = new ArrayList<>(Arrays.asList(getValue(null, "test"), getValue(null, Time.valueOf("09:01:00"))));
      AssertionsOnColumnType.isTime(tableAssert, info, list, false);
      fail("An exception must be raised");
    } catch (AssertionError e) {
      Assertions.assertThat(e.getMessage()).isEqualTo(String.format("[description] %n"
                                                      + "Expecting that the value at index 0:%n"
                                                      + "  <\"test\">%n"
                                                      + "to be of type%n"
                                                      + "  <TIME>%n"
                                                      + "but was of type%n"
                                                      + "  <TEXT>"));
    }
  }

  /**
   * This method should fail because the value is not a time (with lenience).
   */
  @Test
  public void should_fail_because_value_is_not_a_time_with_lenience() throws Exception {
    WritableAssertionInfo info = new WritableAssertionInfo();
    info.description("description");
    Table table = new Table();
    TableAssert tableAssert = assertThat(table);
    try {
      List<Value> list = new ArrayList<>(Arrays.asList(getValue(null, Time.valueOf("09:01:00")), getValue(null, "test")));
      AssertionsOnColumnType.isTime(tableAssert, info, list, false);
      fail("An exception must be raised");
    } catch (AssertionError e) {
      Assertions.assertThat(e.getMessage()).isEqualTo(String.format("[description] %n"
                                                      + "Expecting that the value at index 1:%n"
                                                      + "  <\"test\">%n"
                                                      + "to be of type%n"
                                                      + "  <TIME>%n"
                                                      + "but was of type%n"
                                                      + "  <TEXT>"));
    }
  }

  /**
   * This method should fail because the value is a stringbuiler.
   */
  @Test
  public void should_fail_because_value_is_a_stringbuilder() throws Exception {
    WritableAssertionInfo info = new WritableAssertionInfo();
    info.description("description");
    Table table = new Table();
    TableAssert tableAssert = assertThat(table);
    try {
      List<Value> list = new ArrayList<>(Arrays.asList(getValue(null, new StringBuilder("test")), getValue(null, true)));
      AssertionsOnColumnType.isTime(tableAssert, info, list, false);
      fail("An exception must be raised");
    } catch (AssertionError e) {
      Assertions.assertThat(e.getMessage()).isEqualTo(String.format("[description] %n"
                                                                    + "Expecting that the value at index 0:%n"
                                                                    + "  <test>%n"
                                                                    + "to be of type%n"
                                                                    + "  <TIME>%n"
                                                                    + "but was of type%n"
                                                                    + "  <NOT_IDENTIFIED> (java.lang.StringBuilder)"));
    }
  }
}

redpajama_set_name: RedPajamaGithub


text:
package com.guoxiaoxing.cloud.music.service.download;

public interface DownloadTaskListener {
    void onPrepare(DownloadTask downloadTask);

    void onStart(DownloadTask downloadTask);

    void onDownloading(DownloadTask downloadTask);

    void onPause(DownloadTask downloadTask);

    void onCancel(DownloadTask downloadTask);

    void onCompleted(DownloadTask downloadTask);

    void onError(DownloadTask downloadTask, int errorCode);

    int DOWNLOAD_ERROR_FILE_NOT_FOUND = -1;
    int DOWNLOAD_ERROR_IO_ERROR = -2;

}


text:
/**
 * Created by huy on 6/27/2016.
 */

angular.module('app').constant('ConstantValues', {

    cacheMaxAge: 5*60*1000, //cache is kept in 5 mins
    cacheAutoFlushInterval:60*60*1000, // This cache will clear itself every hour.
    greenTimeOut: 15*60 *1000, // 15 mins gets yellow
    redTimeout: 2*24*60*60*1000, //yellow before 2 days, after which comes the red
    clientsAutoUpdateInterval: 5*60*1000, //clear cache and auto fetch occurs each 5 minutes
    clientAutoUpdateInterval: 30*1000

});
angular.module('app').config(function ($routeProvider, CSServiceProvider, $httpProvider) {

    CSServiceProvider.configure("something");

    $routeProvider.when('/login', {
        controller: 'LoginController',
        templateUrl: 'partials/login.html',
        hideMenus: true
    }).when('/', {
        templateUrl: 'partials/clients.html',
        leftNav: 'partials/left-nav-main.html',
        topNav: 'partials/top-nav.html',
        controller: 'ClientListviewController'
    }).when('/clients', {
        templateUrl: 'partials/clients.html',
        leftNav: 'partials/left-nav-main.html',
        topNav: 'partials/top-nav.html',
        controller: 'ClientListviewController'
    }).when('/clients/:id', {
        templateUrl: 'partials/client.html',
        leftNav: 'partials/left-nav-main.html',
        topNav: 'partials/top-nav.html',
        controller: 'ClientDetailController'
    }).when('/applications', {
        templateUrl: 'partials/applications.html',
        leftNav: 'partials/left-nav-main.html',
        topNav: 'partials/top-nav.html',
        controller: 'ApplicationListviewController'
    }).when('/applications/:id/:artifactId', {
        templateUrl: 'partials/application.html',
        leftNav: 'partials/left-nav-main.html',
        topNav: 'partials/top-nav.html',
        controller: 'ApplicationDetailController'
    }).when('/application/new', {
        templateUrl: 'partials/application-edit.html',
        leftNav: 'partials/left-nav-main.html',
        topNav: 'partials/top-nav.html',
        controller: 'ApplicationDetailController'
    }).when('/application/new/:artifactId/:configId', {
        templateUrl: 'partials/application-edit.html',
        leftNav: 'partials/left-nav-main.html',
        topNav: 'partials/top-nav.html',
        controller: 'ApplicationDetailController'
    }).when('/application/edit/:id', {
        templateUrl: 'partials/application-edit.html',
        leftNav: 'partials/left-nav-main.html',
        topNav: 'partials/top-nav.html',
        controller: 'ApplicationDetailController'
    });

}).run(['$rootScope', '$location', '$cookieStore', '$http',
    function ($rootScope, $location, $cookieStore, $http) {
        // keep user logged in after page refresh
        $rootScope.globals = $cookieStore.get('globals') || {};
        if ($rootScope.globals.currentUser) {
            $http.defaults.headers.common['Authorization'] = 'Basic ' + $rootScope.globals.currentUser.authdata; // jshint ignore:line
        }

        $rootScope.$on('$locationChangeStart', function (event, next, current) {
            // redirect to login page if not logged in
            if ($location.path() !== '/login' && !$rootScope.globals.currentUser) {
                $location.path('/login');
            }
        });
    }]);


text:
#import "NSObject.h"

// Not exported
@interface SCRCRawImage : NSObject
{
    struct CGImage *_imageRef;
    char *_data;
    long long _width;
    long long _height;
    long long _bytesPerPixel;
}

+ (id)rawImageForImage:(struct CGImage *)arg1;
@property(nonatomic) long long bytesPerPixel; // @synthesize bytesPerPixel=_bytesPerPixel;
@property(nonatomic) long long height; // @synthesize height=_height;
@property(nonatomic) long long width; // @synthesize width=_width;
@property(nonatomic) char *data; // @synthesize data=_data;
@property(retain, nonatomic) struct CGImage *imageRef; // @synthesize imageRef=_imageRef;
- (void)dealloc;

@end


text:
<?php
declare(strict_types=1);

namespace Edde\Schema;

interface UuidSchema {
    const primary = 'uuid';

    public function uuid($type = 'uuid', $required = true);
}


text:
package com.hack23.cia.service.api.action.admin;

import com.hack23.cia.service.api.action.common.AbstractResponse;

/**
 * The Class SendEmailResponse.
 */
public final class SendEmailResponse extends AbstractResponse {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/**
	 * Instantiates a new update search index response.
	 *
	 * @param result
	 *            the result
	 */
	public SendEmailResponse(final ServiceResult result) {
		super(result);
	}

}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
InvocationSequence (lambdaj 1.8 API)
</TITLE>

<META NAME="date" CONTENT="2009-05-10">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

      Overview
      Package
    Class
      Use
      Tree
      Deprecated
      Index
      Help

 PREV CLASS
 NEXT CLASS

  FRAMES
 NO FRAMES

  All Classes

  SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

ch.lambdaj.function.argument

Class InvocationSequence

java.lang.Object
  java.util.AbstractCollection<E>
      java.util.AbstractList<E>
          java.util.ArrayList<Invocation>
              ch.lambdaj.function.argument.InvocationSequence

All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Invocation>, java.util.Collection<Invocation>, java.util.List<Invocation>, java.util.RandomAccess

public class InvocationSequence
extends java.util.ArrayList<Invocation>

See Also:
Serialized Form

Field Summary

Fields inherited from class java.util.AbstractList

modCount

Method Summary

 boolean
equals(java.lang.Object object)

 java.lang.String
getInkvokedPropertyName()

 java.lang.Class<?>
getRootInvokedClass()

 int
hashCode()

Methods inherited from class java.util.ArrayList

add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize

Methods inherited from class java.util.AbstractList

iterator, listIterator, listIterator, subList

Methods inherited from class java.util.AbstractCollection

containsAll, removeAll, retainAll, toString

Methods inherited from class java.lang.Object

finalize, getClass, notify, notifyAll, wait, wait, wait

Methods inherited from interface java.util.List

containsAll, iterator, listIterator, listIterator, removeAll, retainAll, subList

Method Detail

getRootInvokedClass

public java.lang.Class<?> getRootInvokedClass()

getInkvokedPropertyName

public java.lang.String getInkvokedPropertyName()

equals

public boolean equals(java.lang.Object object)

Specified by:
equals in interface java.util.Collection<Invocation>
Specified by:
equals in interface java.util.List<Invocation>
Overrides:
equals in class java.util.AbstractList<Invocation>

hashCode

public int hashCode()

Specified by:
hashCode in interface java.util.Collection<Invocation>
Specified by:
hashCode in interface java.util.List<Invocation>
Overrides:
hashCode in class java.util.AbstractList<Invocation>

      Overview
      Package
    Class
      Use
      Tree
      Deprecated
      Index
      Help

 PREV CLASS
 NEXT CLASS

  FRAMES
 NO FRAMES

  All Classes

  SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009. All Rights Reserved.


text:
package org.apache.calcite.sql.fun;

import org.apache.calcite.sql.SqlFunction;
import org.apache.calcite.sql.SqlFunctionCategory;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.type.OperandTypes;
import org.apache.calcite.sql.type.ReturnTypes;
import org.apache.calcite.sql.type.SqlTypeFamily;
import org.apache.calcite.sql.type.SqlTypeTransforms;

/**
 * The JSON_LENGTH function.
 */
public class SqlJsonLengthFunction extends SqlFunction {
  public SqlJsonLengthFunction() {
    super("JSON_LENGTH", SqlKind.OTHER_FUNCTION,
        ReturnTypes.cascade(ReturnTypes.INTEGER,
            SqlTypeTransforms.FORCE_NULLABLE),
        null,
        OperandTypes.or(OperandTypes.ANY,
            OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER)),
        SqlFunctionCategory.SYSTEM);
  }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>game-of-life</artifactId>
        <groupId>org.pwr.hpc</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>gol-cell-cpu-impl</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.pwr.hpc</groupId>
            <artifactId>gol-cell-api</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

</project>


text:
[![DOI](https://zenodo.org/badge/47938283.svg)](https://zenodo.org/badge/latestdoi/47938283)

[![Coverage Status](https://coveralls.io/repos/github/JuliaChem/NumOptim.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaChem/NumOptim.jl?branch=master)

[![Build Status](https://travis-ci.org/JuliaChem/NumOptim.jl.svg?branch=master)](https://travis-ci.org/JuliaChem/NumOptim.jl)

Numerical optimization algorithms written in pure Julia. Includes examples for chemical engineering applications.

This is an unregistred package. To install on Julia use:

    Pkg.clone("git://github.com/JuliaChem/NumOptim.jl")

To track changes across versions, the package should be registered into the local METADATA. Pull requests are always highly welcome to fix bugs, add solvers, or anything else!

# Current status of the project
Current release (v0.0.6), contains the basic functionality.

PhD Kelvyn Baruc Sánchez-Sánchez.
email: kelvyn.baruc@gmail.com

"human knowledge belongs to the world"


text:
/* $Id$ */

#ifndef PHP_HTTP_REQUESTPOOL_OBJECT_H
#define PHP_HTTP_REQUESTPOOL_OBJECT_H
#ifdef HTTP_HAVE_CURL
#ifdef ZEND_ENGINE_2

#ifdef	PHP_WIN32
#	include <winsock2.h>
#endif

#include <curl/curl.h>

#include "php_http_request_pool_api.h"

typedef struct {
	zend_object zo;
	http_request_pool pool;
	struct {
		long pos;
	} iterator;
} http_requestpool_object;

extern zend_class_entry *http_requestpool_object_ce;
extern zend_function_entry http_requestpool_object_fe[];

extern PHP_MINIT_FUNCTION(http_requestpool_object);

#define http_requestpool_object_new(ce) _http_requestpool_object_new(ce TSRMLS_CC)
extern zend_object_value _http_requestpool_object_new(zend_class_entry *ce TSRMLS_DC);
#define http_requestpool_object_free(o) _http_requestpool_object_free(o TSRMLS_CC)
extern void _http_requestpool_object_free(zend_object *object TSRMLS_DC);

PHP_METHOD(HttpRequestPool, __construct);
PHP_METHOD(HttpRequestPool, __destruct);
PHP_METHOD(HttpRequestPool, attach);
PHP_METHOD(HttpRequestPool, detach);
PHP_METHOD(HttpRequestPool, send);
PHP_METHOD(HttpRequestPool, reset);
PHP_METHOD(HttpRequestPool, socketPerform);
PHP_METHOD(HttpRequestPool, socketSelect);
PHP_METHOD(HttpRequestPool, valid);
PHP_METHOD(HttpRequestPool, current);
PHP_METHOD(HttpRequestPool, key);
PHP_METHOD(HttpRequestPool, next);
PHP_METHOD(HttpRequestPool, rewind);
PHP_METHOD(HttpRequestPool, getAttachedRequests);
PHP_METHOD(HttpRequestPool, getFinishedRequests);

#endif
#endif
#endif

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: noet sw=4 ts=4 fdm=marker
 * vim<600: noet sw=4 ts=4
 */


text:
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
// This file is manually converted from PROJ4 (projects.h)

// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
// Copyright Bruno Lalande 2008, 2009
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

// This file is converted from PROJ4, http://trac.osgeo.org/proj
// PROJ4 is originally written by Gerald Evenden (then of the USGS)
// PROJ4 is maintained by Frank Warmerdam
// PROJ4 is converted to Geometry Library by Barend Gehrels (Geodan, Amsterdam)

// Original copyright notice:

// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP

#include <cstring>
#include <string>
#include <vector>

#include <boost/concept_check.hpp>

namespace boost { namespace geometry { namespace projection
{

#ifndef DOXYGEN_NO_DETAIL
namespace detail
{

/* some useful constants */
static const double HALFPI = 1.5707963267948966;
static const double FORTPI = 0.78539816339744833;
static const double PI = 3.14159265358979323846;
static const double TWOPI = 6.2831853071795864769;

static const double RAD_TO_DEG = 57.29577951308232;
static const double DEG_TO_RAD = .0174532925199432958;

static const int PJD_UNKNOWN =0;
static const int PJD_3PARAM = 1;
static const int PJD_7PARAM = 2;
static const int PJD_GRIDSHIFT = 3;
static const int PJD_WGS84 = 4;   /* WGS84 (or anything considered equivelent) */

struct pvalue
{
    std::string param;
    int used;

    int i;
    double f;
    std::string s;
};

struct pj_const_pod
{
    int over;   /* over-range flag */
    int geoc;   /* geocentric latitude flag */
    int is_latlong; /* proj=latlong ... not really a projection at all */
    int is_geocent; /* proj=geocent ... not really a projection at all */
    double
        a,  /* major axis or radius if es==0 */
        a_orig, /* major axis before any +proj related adjustment */
        es, /* e ^ 2 */
        es_orig, /* es before any +proj related adjustment */
        e,  /* eccentricity */
        ra, /* 1/A */
        one_es, /* 1 - e^2 */
        rone_es, /* 1/one_es */
        lam0, phi0, /* central longitude, latitude */
        x0, y0, /* easting and northing */
        k0,    /* general scaling factor */
        to_meter, fr_meter; /* cartesian scaling */

    int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
    double  datum_params[7];
    double  from_greenwich; /* prime meridian offset (in radians) */
    double  long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/

    // Initialize all variables to zero
    pj_const_pod()
    {
        std::memset(this, 0, sizeof(pj_const_pod));
    }
};

// PROJ4 complex. Might be replaced with std::complex
struct COMPLEX { double r, i; };

struct PJ_ELLPS
{
    std::string id;    /* ellipse keyword name */
    std::string major;    /* a= value */
    std::string ell;    /* elliptical parameter */
    std::string name;    /* comments */
};

struct PJ_DATUMS
{
    std::string id;     /* datum keyword */
    std::string defn;   /* ie. "to_wgs84=..." */
    std::string ellipse_id; /* ie from ellipse table */
    std::string comments; /* EPSG code, etc */
};

struct PJ_PRIME_MERIDIANS
{
    std::string id;     /* prime meridian keyword */
    std::string defn;   /* offset from greenwich in DMS format. */
};

struct PJ_UNITS
{
    std::string id;    /* units keyword */
    std::string to_meter;    /* multiply by value to get meters */
    std::string name;    /* comments */
};

struct DERIVS
{
    double x_l, x_p; /* derivatives of x for lambda-phi */
    double y_l, y_p; /* derivatives of y for lambda-phi */
};

struct FACTORS
{
    struct DERIVS der;
    double h, k;    /* meridinal, parallel scales */
    double omega, thetap;    /* angular distortion, theta prime */
    double conv;    /* convergence */
    double s;        /* areal scale factor */
    double a, b;    /* max-min scale error */
    int code;        /* info as to analytics, see following */
};

} // namespace detail
#endif // DOXYGEN_NO_DETAIL

/*!
    \brief parameters, projection parameters
    \details This structure initializes all projections
    \ingroup projection
*/
struct parameters : public detail::pj_const_pod
{
    std::string name;
    std::vector<detail::pvalue> params;
};

// TODO: derived from boost::exception / make more for forward/inverse/init/setup
class proj_exception
{
public:

    proj_exception(int code = 0)
    {
        boost::ignore_unused_variable_warning(code);
    }
};

}}} // namespace boost::geometry::projection
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP


text:
package io.sitoolkit.wt.domain.operation;

import org.junit.Test;
import io.sitoolkit.wt.domain.tester.TestBase;

/**
 *
 * @author yuichi.kuwahara
 */
public class GoToOperationTest extends TestBase {

  @Test
  public void test001() {
    test();
  }

  @Override
  protected String getTestScriptPath() {
    return "src/test/resources/GoToTestScript.csv";
  }

  @Override
  protected String getSheetName() {
    return "TestScript";
  }
}


text:
<title> / linq.lamdba.DefaultLambdaFunctions.LeftShift</title>
<link rel="stylesheet" href="..\..\style.css">

linq.lamdba / DefaultLambdaFunctions / LeftShift

LeftShift

fun LeftShift(a: Int, b: Int): Int

fun LeftShift(a: Long, b: Long): Long


text:
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems                */
/*                                                                            */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
/* not use this file except in compliance with the License. You may obtain    */
/* a copy of the License at                                                   */
/*                                                                            */
/* http://www.apache.org/licenses/LICENSE-2.0                                 */
/*                                                                            */
/* Unless required by applicable law or agreed to in writing, software        */
/* distributed under the License is distributed on an "AS IS" BASIS,          */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
/* See the License for the specific language governing permissions and        */
/* limitations under the License.                                             */
/* -------------------------------------------------------------------------- */

define(function(require) {
  /*
    DEPENDENCIES
   */

  var Locale = require('utils/locale');
  var HostsTable = require('tabs/hosts-tab/datatable');

  /*
    CONSTANTS
   */

  var PANEL_ID = require('./hosts/panelId');
  var HOSTS_TABLE_ID = PANEL_ID + "HostsTable";
  var RESOURCE = "Cluster";
  var XML_ROOT = "CLUSTER";

  /*
    CONSTRUCTOR
   */

  function Panel(info) {
    this.title = Locale.tr("Hosts");
    this.icon = "fa-hdd";

    this.element = info[XML_ROOT];

    return this;
  }

  Panel.PANEL_ID = PANEL_ID;
  Panel.prototype.html = _html;
  Panel.prototype.setup = _setup;

  return Panel;

  /*
    FUNCTION DEFINITIONS
   */

  function _html() {
    var hosts = [];

    if (this.element.HOSTS.ID != undefined){
      hosts = this.element.HOSTS.ID;

      if (!$.isArray(hosts)){
        hosts = [hosts];
      }
    }

    var opts = {
      info: true,
      select: true,
      selectOptions: {
        read_only: true,
        fixed_ids: hosts
      }
    };

    this.HostsTable = new HostsTable(HOSTS_TABLE_ID, opts);

    return this.HostsTable.dataTableHTML;
  }

  function _setup(context) {
    this.HostsTable.initialize();
    this.HostsTable.refreshResourceTableSelect();

    return false;
  }
});


text:
001
017    package org.apache.commons.math3.util;
018
019    import java.io.Serializable;
020    import java.util.Arrays;
021
022    import org.apache.commons.math3.exception.MathIllegalArgumentException;
023    import org.apache.commons.math3.exception.MathIllegalStateException;
024    import org.apache.commons.math3.exception.MathInternalError;
025    import org.apache.commons.math3.exception.NullArgumentException;
026    import org.apache.commons.math3.exception.NotStrictlyPositiveException;
027    import org.apache.commons.math3.exception.NumberIsTooSmallException;
028    import org.apache.commons.math3.exception.util.LocalizedFormats;
029
030    /**
031     * <p>
032     * A variable length {@link DoubleArray} implementation that automatically
033     * handles expanding and contracting its internal storage array as elements
034     * are added and removed.
035     * </p>
036     * <h3>Important note: Usage should not assume that this class is thread-safe
037     * even though some of the methods are {@code synchronized}.
038     * This qualifier will be dropped in the next major release (4.0).</h3>
039     * <p>
040     * The internal storage array starts with capacity determined by the
041     * {@code initialCapacity} property, which can be set by the constructor.
042     * The default initial capacity is 16.  Adding elements using
043     * {@link #addElement(double)} appends elements to the end of the array.
044     * When there are no open entries at the end of the internal storage array,
045     * the array is expanded.  The size of the expanded array depends on the
046     * {@code expansionMode} and {@code expansionFactor} properties.
047     * The {@code expansionMode} determines whether the size of the array is
048     * multiplied by the {@code expansionFactor}
049     * ({@link ExpansionMode#MULTIPLICATIVE}) or if the expansion is additive
050     * ({@link ExpansionMode#ADDITIVE} -- {@code expansionFactor} storage
051     * locations added).
052     * The default {@code expansionMode} is {@code MULTIPLICATIVE} and the default
053     * {@code expansionFactor} is 2.
054     * </p>
055     * <p>
056     * The {@link #addElementRolling(double)} method adds a new element to the end
057     * of the internal storage array and adjusts the "usable window" of the
058     * internal array forward by one position (effectively making what was the
059     * second element the first, and so on).  Repeated activations of this method
060     * (or activation of {@link #discardFrontElements(int)}) will effectively orphan
061     * the storage locations at the beginning of the internal storage array.  To
062     * reclaim this storage, each time one of these methods is activated, the size
063     * of the internal storage array is compared to the number of addressable
064     * elements (the {@code numElements} property) and if the difference
065     * is too large, the internal array is contracted to size
066     * {@code numElements + 1}.  The determination of when the internal
067     * storage array is "too large" depends on the {@code expansionMode} and
068     * {@code contractionFactor} properties.  If  the {@code expansionMode}
069     * is {@code MULTIPLICATIVE}, contraction is triggered when the
070     * ratio between storage array length and {@code numElements} exceeds
071     * {@code contractionFactor.}  If the {@code expansionMode}
072     * is {@code ADDITIVE}, the number of excess storage locations
073     * is compared to {@code contractionFactor}.
074     * </p>
075     * <p>
076     * To avoid cycles of expansions and contractions, the
077     * {@code expansionFactor} must not exceed the {@code contractionFactor}.
078     * Constructors and mutators for both of these properties enforce this
079     * requirement, throwing a {@code MathIllegalArgumentException} if it is
080     * violated.
081     * </p>
082     * @version $Id: ResizableDoubleArray.java 1422433 2012-12-16 00:45:18Z erans $
083     */
084    public class ResizableDoubleArray implements DoubleArray, Serializable {
085        /** Additive expansion mode.
086         * @deprecated As of 3.1. Please use {@link ExpansionMode#ADDITIVE} instead.
087         */
088        @Deprecated
089        public static final int ADDITIVE_MODE = 1;
090        /** Multiplicative expansion mode.
091         * @deprecated As of 3.1. Please use {@link ExpansionMode#MULTIPLICATIVE} instead.
092         */
093        @Deprecated
094        public static final int MULTIPLICATIVE_MODE = 0;
095        /** Serializable version identifier. */
096        private static final long serialVersionUID = -3485529955529426875L;
097
098        /** Default value for initial capacity. */
099        private static final int DEFAULT_INITIAL_CAPACITY = 16;
100        /** Default value for array size modifier. */
101        private static final double DEFAULT_EXPANSION_FACTOR = 2.0;
102        /**
103         * Default value for the difference between {@link #contractionCriterion}
104         * and {@link #expansionFactor}.
105         */
106        private static final double DEFAULT_CONTRACTION_DELTA = 0.5;
107
108        /**
109         * The contraction criteria determines when the internal array will be
110         * contracted to fit the number of elements contained in the element
111         *  array + 1.
112         */
113        private double contractionCriterion = 2.5;
114
115        /**
116         * The expansion factor of the array.  When the array needs to be expanded,
117         * the new array size will be
118         * {@code internalArray.length * expansionFactor}
119         * if {@code expansionMode} is set to MULTIPLICATIVE_MODE, or
120         * {@code internalArray.length + expansionFactor} if
121         * {@code expansionMode} is set to ADDITIVE_MODE.
122         */
123        private double expansionFactor = 2.0;
124
125        /**
126         * Determines whether array expansion by {@code expansionFactor}
127         * is additive or multiplicative.
128         */
129        private ExpansionMode expansionMode = ExpansionMode.MULTIPLICATIVE;
130
131        /**
132         * The internal storage array.
133         */
134        private double[] internalArray;
135
136        /**
137         * The number of addressable elements in the array.  Note that this
138         * has nothing to do with the length of the internal storage array.
139         */
140        private int numElements = 0;
141
142        /**
143         * The position of the first addressable element in the internal storage
144         * array.  The addressable elements in the array are
145         * {@code internalArray[startIndex],...,internalArray[startIndex + numElements - 1]}.
146         */
147        private int startIndex = 0;
148
149        /**
150         * Specification of expansion algorithm.
151         * @since 3.1
152         */
153        public static enum ExpansionMode {
154            /** Multiplicative expansion mode. */
155            MULTIPLICATIVE,
156            /** Additive expansion mode. */
157            ADDITIVE
158        }
159
160        /**
161         * Creates an instance with default properties.
162         * <ul>
163         *  <li>{@code initialCapacity = 16}</li>
164         *  <li>{@code expansionMode = MULTIPLICATIVE}</li>
165         *  <li>{@code expansionFactor = 2.0}</li>
166         *  <li>{@code contractionCriterion = 2.5}</li>
167         * </ul>
168         */
169        public ResizableDoubleArray() {
170            this(DEFAULT_INITIAL_CAPACITY);
171        }
172
173        /**
174         * Creates an instance with the specified initial capacity.
175         * Other properties take default values:
176         * <ul>
177         *  <li>{@code expansionMode = MULTIPLICATIVE}</li>
178         *  <li>{@code expansionFactor = 2.0}</li>
179         *  <li>{@code contractionCriterion = 2.5}</li>
180         * </ul>
181         * @param initialCapacity Initial size of the internal storage array.
182         * @throws MathIllegalArgumentException if {@code initialCapacity <= 0}.
183         */
184        public ResizableDoubleArray(int initialCapacity)
185            throws MathIllegalArgumentException {
186            this(initialCapacity, DEFAULT_EXPANSION_FACTOR);
187        }
188
189        /**
190         * Creates an instance from an existing {@code double[]} with the
191         * initial capacity and numElements corresponding to the size of
192         * the supplied {@code double[]} array.
193         * If the supplied array is null, a new empty array with the default
194         * initial capacity will be created.
195         * The input array is copied, not referenced.
196         * Other properties take default values:
197         * <ul>
198         *  <li>{@code initialCapacity = 16}</li>
199         *  <li>{@code expansionMode = MULTIPLICATIVE}</li>
200         *  <li>{@code expansionFactor = 2.0}</li>
201         *  <li>{@code contractionCriterion = 2.5}</li>
202         * </ul>
203         *
204         * @param initialArray initial array
205         * @since 2.2
206         */
207        public ResizableDoubleArray(double[] initialArray) {
208            this(DEFAULT_INITIAL_CAPACITY,
209                 DEFAULT_EXPANSION_FACTOR,
210                 DEFAULT_CONTRACTION_DELTA + DEFAULT_EXPANSION_FACTOR,
211                 ExpansionMode.MULTIPLICATIVE,
212                 initialArray);
213        }
214
215        /**
216         * Creates an instance with the specified initial capacity
217         * and expansion factor.
218         * The remaining properties take default values:
219         * <ul>
220         *  <li>{@code expansionMode = MULTIPLICATIVE}</li>
221         *  <li>{@code contractionCriterion = 0.5 + expansionFactor}</li>
222         * </ul>
223         * <br/>
224         * Throws IllegalArgumentException if the following conditions are
225         * not met:
226         * <ul>
227         *  <li>{@code initialCapacity > 0}</li>
228         *  <li>{@code expansionFactor > 1}</li>
229         * </ul>
230         *
231         * @param initialCapacity Initial size of the internal storage array.
232         * @param expansionFactor The array will be expanded based on this
233         * parameter.
234         * @throws MathIllegalArgumentException if parameters are not valid.
235         * @deprecated As of 3.1. Please use
236         * {@link #ResizableDoubleArray(int,double)} instead.
237         */
238        @Deprecated
239        public ResizableDoubleArray(int initialCapacity,
240                                    float expansionFactor)
241            throws MathIllegalArgumentException {
242            this(initialCapacity,
243                 (double) expansionFactor);
244        }
245
246        /**
247         * Creates an instance with the specified initial capacity
248         * and expansion factor.
249         * The remaining properties take default values:
250         * <ul>
251         *  <li>{@code expansionMode = MULTIPLICATIVE}</li>
252         *  <li>{@code contractionCriterion = 0.5 + expansionFactor}</li>
253         * </ul>
254         * <br/>
255         * Throws IllegalArgumentException if the following conditions are
256         * not met:
257         * <ul>
258         *  <li>{@code initialCapacity > 0}</li>
259         *  <li>{@code expansionFactor > 1}</li>
260         * </ul>
261         *
262         * @param initialCapacity Initial size of the internal storage array.
263         * @param expansionFactor The array will be expanded based on this
264         * parameter.
265         * @throws MathIllegalArgumentException if parameters are not valid.
266         * @since 3.1
267         */
268        public ResizableDoubleArray(int initialCapacity,
269                                    double expansionFactor)
270            throws MathIllegalArgumentException {
271            this(initialCapacity,
272                 expansionFactor,
273                 DEFAULT_CONTRACTION_DELTA + expansionFactor);
274        }
275
276        /**
277         * Creates an instance with the specified initialCapacity,
278         * expansionFactor, and contractionCriterion.
279         * The expansion mode will default to {@code MULTIPLICATIVE}.
280         * <br/>
281         * Throws IllegalArgumentException if the following conditions are
282         * not met:
283         * <ul>
284         *  <li>{@code initialCapacity > 0}</li>
285         *  <li>{@code expansionFactor > 1}</li>
286         *  <li>{@code contractionCriterion >= expansionFactor}</li>
287         * </ul>
288         *
289         * @param initialCapacity Initial size of the internal storage array..
290         * @param expansionFactor The array will be expanded based on this
291         * parameter.
292         * @param contractionCriteria Contraction criteria.
293         * @throws MathIllegalArgumentException if parameters are not valid.
294         * @deprecated As of 3.1. Please use
295         * {@link #ResizableDoubleArray(int,double,double)} instead.
296         */
297        @Deprecated
298        public ResizableDoubleArray(int initialCapacity,
299                                    float expansionFactor,
300                                    float contractionCriteria)
301            throws MathIllegalArgumentException {
302            this(initialCapacity,
303                 (double) expansionFactor,
304                 (double) contractionCriteria);
305        }
306
307        /**
308         * Creates an instance with the specified initial capacity,
309         * expansion factor, and contraction criteria.
310         * The expansion mode will default to {@code MULTIPLICATIVE}.
311         * <br/>
312         * Throws IllegalArgumentException if the following conditions are
313         * not met:
314         * <ul>
315         *  <li>{@code initialCapacity > 0}</li>
316         *  <li>{@code expansionFactor > 1}</li>
317         *  <li>{@code contractionCriterion >= expansionFactor}</li>
318         * </ul>
319         *
320         * @param initialCapacity Initial size of the internal storage array..
321         * @param expansionFactor The array will be expanded based on this
322         * parameter.
323         * @param contractionCriterion Contraction criterion.
324         * @throws MathIllegalArgumentException if the parameters are not valid.
325         * @since 3.1
326         */
327        public ResizableDoubleArray(int initialCapacity,
328                                    double expansionFactor,
329                                    double contractionCriterion)
330            throws MathIllegalArgumentException {
331            this(initialCapacity,
332                 expansionFactor,
333                 contractionCriterion,
334                 ExpansionMode.MULTIPLICATIVE,
335                 null);
336        }
337
338        /**
339         * <p>
340         * Create a ResizableArray with the specified properties.</p>
341         * <p>
342         * Throws IllegalArgumentException if the following conditions are
343         * not met:
344         * <ul>
345         * <li><code>initialCapacity > 0</code></li>
346         * <li><code>expansionFactor > 1</code></li>
347         * <li><code>contractionFactor >= expansionFactor</code></li>
348         * <li><code>expansionMode in {MULTIPLICATIVE_MODE, ADDITIVE_MODE}</code>
349         * </li>
350         * </ul></p>
351         *
352         * @param initialCapacity the initial size of the internal storage array
353         * @param expansionFactor the array will be expanded based on this
354         *                        parameter
355         * @param contractionCriteria the contraction Criteria
356         * @param expansionMode  the expansion mode
357         * @throws MathIllegalArgumentException if parameters are not valid
358         * @deprecated As of 3.1. Please use
359         * {@link #ResizableDoubleArray(int,double,double,ExpansionMode,double[])}
360         * instead.
361         */
362        public ResizableDoubleArray(int initialCapacity, float expansionFactor,
363                float contractionCriteria, int expansionMode) throws MathIllegalArgumentException {
364            this(initialCapacity,
365                 expansionFactor,
366                 contractionCriteria,
367                 expansionMode == ADDITIVE_MODE ?
368                 ExpansionMode.ADDITIVE :
369                 ExpansionMode.MULTIPLICATIVE,
370                 null);
371            // XXX Just ot retain the expected failure in a unit test.
372            // With the new "enum", that test will become obsolete.
373            setExpansionMode(expansionMode);
374        }
375
376        /**
377         * Creates an instance with the specified properties.
378         * <br/>
379         * Throws MathIllegalArgumentException if the following conditions are
380         * not met:
381         * <ul>
382         *  <li>{@code initialCapacity > 0}</li>
383         *  <li>{@code expansionFactor > 1}</li>
384         *  <li>{@code contractionCriterion >= expansionFactor}</li>
385         * </ul>
386         *
387         * @param initialCapacity Initial size of the internal storage array.
388         * @param expansionFactor The array will be expanded based on this
389         * parameter.
390         * @param contractionCriterion Contraction criteria.
391         * @param expansionMode Expansion mode.
392         * @param data Initial contents of the array.
393         * @throws MathIllegalArgumentException if the parameters are not valid.
394         */
395        public ResizableDoubleArray(int initialCapacity,
396                                    double expansionFactor,
397                                    double contractionCriterion,
398                                    ExpansionMode expansionMode,
399                                    double ... data)
400            throws MathIllegalArgumentException {
401            if (initialCapacity <= 0) {
402                throw new NotStrictlyPositiveException(LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE,
403                                                       initialCapacity);
404            }
405            checkContractExpand(contractionCriterion, expansionFactor);
406
407            this.expansionFactor = expansionFactor;
408            this.contractionCriterion = contractionCriterion;
409            this.expansionMode = expansionMode;
410            internalArray = new double[initialCapacity];
411            numElements = 0;
412            startIndex = 0;
413
414            if (data != null) {
415                addElements(data);
416            }
417        }
418
419        /**
420         * Copy constructor.  Creates a new ResizableDoubleArray that is a deep,
421         * fresh copy of the original. Needs to acquire synchronization lock
422         * on original.  Original may not be null; otherwise a {@link NullArgumentException}
423         * is thrown.
424         *
425         * @param original array to copy
426         * @exception NullArgumentException if original is null
427         * @since 2.0
428         */
429        public ResizableDoubleArray(ResizableDoubleArray original)
430            throws NullArgumentException {
431            MathUtils.checkNotNull(original);
432            copy(original, this);
433        }
434
435        /**
436         * Adds an element to the end of this expandable array.
437         *
438         * @param value Value to be added to end of array.
439         */
440        public synchronized void addElement(double value) {
441            if (internalArray.length <= startIndex + numElements) {
442                expand();
443            }
444            internalArray[startIndex + numElements++] = value;
445        }
446
447        /**
448         * Adds several element to the end of this expandable array.
449         *
450         * @param values Values to be added to end of array.
451         * @since 2.2
452         */
453        public synchronized void addElements(double[] values) {
454            final double[] tempArray = new double[numElements + values.length + 1];
455            System.arraycopy(internalArray, startIndex, tempArray, 0, numElements);
456            System.arraycopy(values, 0, tempArray, numElements, values.length);
457            internalArray = tempArray;
458            startIndex = 0;
459            numElements += values.length;
460        }
461
462        /**
463         * <p>
464         * Adds an element to the end of the array and removes the first
465         * element in the array.  Returns the discarded first element.
466         * The effect is similar to a push operation in a FIFO queue.
467         * </p>
468         * <p>
469         * Example: If the array contains the elements 1, 2, 3, 4 (in that order)
470         * and addElementRolling(5) is invoked, the result is an array containing
471         * the entries 2, 3, 4, 5 and the value returned is 1.
472         * </p>
473         *
474         * @param value Value to be added to the array.
475         * @return the value which has been discarded or "pushed" out of the array
476         * by this rolling insert.
477         */
478        public synchronized double addElementRolling(double value) {
479            double discarded = internalArray[startIndex];
480
481            if ((startIndex + (numElements + 1)) > internalArray.length) {
482                expand();
483            }
484            // Increment the start index
485            startIndex += 1;
486
487            // Add the new value
488            internalArray[startIndex + (numElements - 1)] = value;
489
490            // Check the contraction criterion.
491            if (shouldContract()) {
492                contract();
493            }
494            return discarded;
495        }
496
497        /**
498         * Substitutes <code>value</code> for the most recently added value.
499         * Returns the value that has been replaced. If the array is empty (i.e.
500         * if {@link #numElements} is zero), an IllegalStateException is thrown.
501         *
502         * @param value New value to substitute for the most recently added value
503         * @return the value that has been replaced in the array.
504         * @throws MathIllegalStateException if the array is empty
505         * @since 2.0
506         */
507        public synchronized double substituteMostRecentElement(double value)
508            throws MathIllegalStateException {
509            if (numElements < 1) {
510                throw new MathIllegalStateException(
511                        LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
512            }
513
514            final int substIndex = startIndex + (numElements - 1);
515            final double discarded = internalArray[substIndex];
516
517            internalArray[substIndex] = value;
518
519            return discarded;
520        }
521
522        /**
523         * Checks the expansion factor and the contraction criterion and throws an
524         * IllegalArgumentException if the contractionCriteria is less than the
525         * expansionCriteria
526         *
527         * @param expansion factor to be checked
528         * @param contraction criteria to be checked
529         * @throws MathIllegalArgumentException if the contractionCriteria is less than
530         * the expansionCriteria.
531         * @deprecated As of 3.1. Please use
532         * {@link #checkContractExpand(double,double)} instead.
533         */
534        protected void checkContractExpand(float contraction, float expansion)
535            throws MathIllegalArgumentException {
536            checkContractExpand((double) contraction,
537                                (double) expansion);
538        }
539
540        /**
541         * Checks the expansion factor and the contraction criterion and raises
542         * an exception if the contraction criterion is smaller than the
543         * expansion criterion.
544         *
545         * @param contraction Criterion to be checked.
546         * @param expansion Factor to be checked.
547         * @throws NumberIsTooSmallException if {@code contraction < expansion}.
548         * @throws NumberIsTooSmallException if {@code contraction <= 1}.
549         * @throws NumberIsTooSmallException if {@code expansion <= 1 }.
550         * @since 3.1
551         */
552        protected void checkContractExpand(double contraction,
553                                           double expansion)
554            throws NumberIsTooSmallException {
555            if (contraction < expansion) {
556                final NumberIsTooSmallException e = new NumberIsTooSmallException(contraction, 1, true);
557                e.getContext().addMessage(LocalizedFormats.CONTRACTION_CRITERIA_SMALLER_THAN_EXPANSION_FACTOR,
558                                          contraction, expansion);
559                throw e;
560            }
561
562            if (contraction <= 1) {
563                final NumberIsTooSmallException e = new NumberIsTooSmallException(contraction, 1, false);
564                e.getContext().addMessage(LocalizedFormats.CONTRACTION_CRITERIA_SMALLER_THAN_ONE,
565                                          contraction);
566                throw e;
567            }
568
569            if (expansion <= 1) {
570                final NumberIsTooSmallException e = new NumberIsTooSmallException(contraction, 1, false);
571                e.getContext().addMessage(LocalizedFormats.EXPANSION_FACTOR_SMALLER_THAN_ONE,
572                                          expansion);
573                throw e;
574            }
575        }
576
577        /**
578         * Clear the array contents, resetting the number of elements to zero.
579         */
580        public synchronized void clear() {
581            numElements = 0;
582            startIndex = 0;
583        }
584
585        /**
586         * Contracts the storage array to the (size of the element set) + 1 - to
587         * avoid a zero length array. This function also resets the startIndex to
588         * zero.
589         */
590        public synchronized void contract() {
591            final double[] tempArray = new double[numElements + 1];
592
593            // Copy and swap - copy only the element array from the src array.
594            System.arraycopy(internalArray, startIndex, tempArray, 0, numElements);
595            internalArray = tempArray;
596
597            // Reset the start index to zero
598            startIndex = 0;
599        }
600
601        /**
602         * Discards the <code>i</code> initial elements of the array.  For example,
603         * if the array contains the elements 1,2,3,4, invoking
604         * <code>discardFrontElements(2)</code> will cause the first two elements
605         * to be discarded, leaving 3,4 in the array.  Throws illegalArgumentException
606         * if i exceeds numElements.
607         *
608         * @param i  the number of elements to discard from the front of the array
609         * @throws MathIllegalArgumentException if i is greater than numElements.
610         * @since 2.0
611         */
612        public synchronized void discardFrontElements(int i)
613            throws MathIllegalArgumentException {
614            discardExtremeElements(i,true);
615        }
616
617        /**
618         * Discards the <code>i</code> last elements of the array.  For example,
619         * if the array contains the elements 1,2,3,4, invoking
620         * <code>discardMostRecentElements(2)</code> will cause the last two elements
621         * to be discarded, leaving 1,2 in the array.  Throws illegalArgumentException
622         * if i exceeds numElements.
623         *
624         * @param i  the number of elements to discard from the end of the array
625         * @throws MathIllegalArgumentException if i is greater than numElements.
626         * @since 2.0
627         */
628        public synchronized void discardMostRecentElements(int i)
629            throws MathIllegalArgumentException {
630            discardExtremeElements(i,false);
631        }
632
633        /**
634         * Discards the <code>i</code> first or last elements of the array,
635         * depending on the value of <code>front</code>.
636         * For example, if the array contains the elements 1,2,3,4, invoking
637         * <code>discardExtremeElements(2,false)</code> will cause the last two elements
638         * to be discarded, leaving 1,2 in the array.
639         * For example, if the array contains the elements 1,2,3,4, invoking
640         * <code>discardExtremeElements(2,true)</code> will cause the first two elements
641         * to be discarded, leaving 3,4 in the array.
642         * Throws illegalArgumentException
643         * if i exceeds numElements.
644         *
645         * @param i  the number of elements to discard from the front/end of the array
646         * @param front true if elements are to be discarded from the front
647         * of the array, false if elements are to be discarded from the end
648         * of the array
649         * @throws MathIllegalArgumentException if i is greater than numElements.
650         * @since 2.0
651         */
652        private synchronized void discardExtremeElements(int i,
653                                                         boolean front)
654            throws MathIllegalArgumentException {
655            if (i > numElements) {
656                throw new MathIllegalArgumentException(
657                        LocalizedFormats.TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY,
658                        i, numElements);
659           } else if (i < 0) {
660               throw new MathIllegalArgumentException(
661                       LocalizedFormats.CANNOT_DISCARD_NEGATIVE_NUMBER_OF_ELEMENTS,
662                       i);
663            } else {
664                // "Subtract" this number of discarded from numElements
665                numElements -= i;
666                if (front) {
667                    startIndex += i;
668                }
669            }
670            if (shouldContract()) {
671                contract();
672            }
673        }
674
675        /**
676         * Expands the internal storage array using the expansion factor.
677         * <p>
678         * if <code>expansionMode</code> is set to MULTIPLICATIVE_MODE,
679         * the new array size will be <code>internalArray.length * expansionFactor.</code>
680         * If <code>expansionMode</code> is set to ADDITIVE_MODE,  the length
681         * after expansion will be <code>internalArray.length + expansionFactor</code>
682         * </p>
683         */
684        protected synchronized void expand() {
685            // notice the use of FastMath.ceil(), this guarantees that we will always
686            // have an array of at least currentSize + 1.   Assume that the
687            // current initial capacity is 1 and the expansion factor
688            // is 1.000000000000000001.  The newly calculated size will be
689            // rounded up to 2 after the multiplication is performed.
690            int newSize = 0;
691            if (expansionMode == ExpansionMode.MULTIPLICATIVE) {
692                newSize = (int) FastMath.ceil(internalArray.length * expansionFactor);
693            } else {
694                newSize = (int) (internalArray.length + FastMath.round(expansionFactor));
695            }
696            final double[] tempArray = new double[newSize];
697
698            // Copy and swap
699            System.arraycopy(internalArray, 0, tempArray, 0, internalArray.length);
700            internalArray = tempArray;
701        }
702
703        /**
704         * Expands the internal storage array to the specified size.
705         *
706         * @param size Size of the new internal storage array.
707         */
708        private synchronized void expandTo(int size) {
709            final double[] tempArray = new double[size];
710            // Copy and swap
711            System.arraycopy(internalArray, 0, tempArray, 0, internalArray.length);
712            internalArray = tempArray;
713        }
714
715        /**
716         * The contraction criteria defines when the internal array will contract
717         * to store only the number of elements in the element array.
718         * If  the <code>expansionMode</code> is <code>MULTIPLICATIVE_MODE</code>,
719         * contraction is triggered when the ratio between storage array length
720         * and <code>numElements</code> exceeds <code>contractionFactor</code>.
721         * If the <code>expansionMode</code> is <code>ADDITIVE_MODE</code>, the
722         * number of excess storage locations is compared to
723         * <code>contractionFactor.</code>
724         *
725         * @return the contraction criteria used to reclaim memory.
726         * @deprecated As of 3.1. Please use {@link #getContractionCriterion()}
727         * instead.
728         */
729        @Deprecated
730        public float getContractionCriteria() {
731            return (float) getContractionCriterion();
732        }
733
734        /**
735         * The contraction criterion defines when the internal array will contract
736         * to store only the number of elements in the element array.
737         * If  the <code>expansionMode</code> is <code>MULTIPLICATIVE_MODE</code>,
738         * contraction is triggered when the ratio between storage array length
739         * and <code>numElements</code> exceeds <code>contractionFactor</code>.
740         * If the <code>expansionMode</code> is <code>ADDITIVE_MODE</code>, the
741         * number of excess storage locations is compared to
742         * <code>contractionFactor.</code>
743         *
744         * @return the contraction criterion used to reclaim memory.
745         * @since 3.1
746         */
747        public double getContractionCriterion() {
748            return contractionCriterion;
749        }
750
751        /**
752         * Returns the element at the specified index
753         *
754         * @param index index to fetch a value from
755         * @return value stored at the specified index
756         * @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than
757         * zero or is greater than <code>getNumElements() - 1</code>.
758         */
759        public synchronized double getElement(int index) {
760            if (index >= numElements) {
761                throw new ArrayIndexOutOfBoundsException(index);
762            } else if (index >= 0) {
763                return internalArray[startIndex + index];
764            } else {
765                throw new ArrayIndexOutOfBoundsException(index);
766            }
767        }
768
769         /**
770         * Returns a double array containing the elements of this
771         * <code>ResizableArray</code>.  This method returns a copy, not a
772         * reference to the underlying array, so that changes made to the returned
773         *  array have no effect on this <code>ResizableArray.</code>
774         * @return the double array.
775         */
776        public synchronized double[] getElements() {
777            final double[] elementArray = new double[numElements];
778            System.arraycopy(internalArray, startIndex, elementArray, 0, numElements);
779            return elementArray;
780        }
781
782        /**
783         * The expansion factor controls the size of a new array when an array
784         * needs to be expanded.  The <code>expansionMode</code>
785         * determines whether the size of the array is multiplied by the
786         * <code>expansionFactor</code> (MULTIPLICATIVE_MODE) or if
787         * the expansion is additive (ADDITIVE_MODE -- <code>expansionFactor</code>
788         * storage locations added).  The default <code>expansionMode</code> is
789         * MULTIPLICATIVE_MODE and the default <code>expansionFactor</code>
790         * is 2.0.
791         *
792         * @return the expansion factor of this expandable double array
793         * @deprecated As of 3.1. Return type will be changed to "double" in 4.0.
794         */
795        @Deprecated
796        public float getExpansionFactor() {
797            return (float) expansionFactor;
798        }
799
800        /**
801         * The expansion mode determines whether the internal storage
802         * array grows additively or multiplicatively when it is expanded.
803         *
804         * @return the expansion mode.
805         * @deprecated As of 3.1. Return value to be changed to
806         * {@link ExpansionMode} in 4.0.
807         */
808        public int getExpansionMode() {
809            switch (expansionMode) {
810            case MULTIPLICATIVE:
811                return MULTIPLICATIVE_MODE;
812            case ADDITIVE:
813                return ADDITIVE_MODE;
814            default:
815                throw new MathInternalError(); // Should never happen.
816            }
817        }
818
819        /**
820         * Notice the package scope on this method.   This method is simply here
821         * for the JUnit test, it allows us check if the expansion is working
822         * properly after a number of expansions.  This is not meant to be a part
823         * of the public interface of this class.
824         *
825         * @return the length of the internal storage array.
826         * @deprecated As of 3.1. Please use {@link #getCapacity()} instead.
827         */
828        @Deprecated
829        synchronized int getInternalLength() {
830            return internalArray.length;
831        }
832
833        /**
834         * Gets the currently allocated size of the internal data structure used
835         * for storing elements.
836         * This is not to be confused with {@link #getNumElements() the number of
837         * elements actually stored}.
838         *
839         * @return the length of the internal array.
840         * @since 3.1
841         */
842        public int getCapacity() {
843            return internalArray.length;
844        }
845
846        /**
847         * Returns the number of elements currently in the array.  Please note
848         * that this is different from the length of the internal storage array.
849         *
850         * @return the number of elements.
851         */
852        public synchronized int getNumElements() {
853            return numElements;
854        }
855
856        /**
857         * Returns the internal storage array.  Note that this method returns
858         * a reference to the internal storage array, not a copy, and to correctly
859         * address elements of the array, the <code>startIndex</code> is
860         * required (available via the {@link #start} method).  This method should
861         * only be used in cases where copying the internal array is not practical.
862         * The {@link #getElements} method should be used in all other cases.
863         *
864         *
865         * @return the internal storage array used by this object
866         * @since 2.0
867         * @deprecated As of 3.1.
868         */
869        @Deprecated
870        public synchronized double[] getInternalValues() {
871            return internalArray;
872        }
873
874        /**
875         * Provides <em>direct</em> access to the internal storage array.
876         * Please note that this method returns a reference to this object's
877         * storage array, not a copy.
878         * <br/>
879         * To correctly address elements of the array, the "start index" is
880         * required (available via the {@link #getStartIndex() getStartIndex}
881         * method.
882         * <br/>
883         * This method should only be used to avoid copying the internal array.
884         * The returned value <em>must</em> be used for reading only; other
885         * uses could lead to this object becoming inconsistent.
886         * <br/>
887         * The {@link #getElements} method has no such limitation since it
888         * returns a copy of this array's addressable elements.
889         *
890         * @return the internal storage array used by this object.
891         * @since 3.1
892         */
893        protected double[] getArrayRef() {
894            return internalArray;
895        }
896
897        /**
898         * Returns the "start index" of the internal array.
899         * This index is the position of the first addressable element in the
900         * internal storage array.
901         * The addressable elements in the array are at indices contained in
902         * the interval [{@link #getStartIndex()},
903         *               {@link #getStartIndex()} + {@link #getNumElements()} - 1].
904         *
905         * @return the start index.
906         * @since 3.1
907         */
908        protected int getStartIndex() {
909            return startIndex;
910        }
911
912        /**
913         * Sets the contraction criteria.
914         *
915         * @param contractionCriteria contraction criteria
916         * @throws MathIllegalArgumentException if the contractionCriteria is less than
917         *         the expansionCriteria.
918         * @deprecated As of 3.1 (to be removed in 4.0 as field will become "final").
919         */
920        @Deprecated
921        public void setContractionCriteria(float contractionCriteria)
922            throws MathIllegalArgumentException {
923            checkContractExpand(contractionCriteria, getExpansionFactor());
924            synchronized(this) {
925                this.contractionCriterion = contractionCriteria;
926            }
927        }
928
929        /**
930         * Performs an operation on the addressable elements of the array.
931         *
932         * @param f Function to be applied on this array.
933         * @return the result.
934         * @since 3.1
935         */
936        public double compute(MathArrays.Function f) {
937            return f.evaluate(internalArray, startIndex, numElements);
938        }
939
940        /**
941         * Sets the element at the specified index.  If the specified index is greater than
942         * <code>getNumElements() - 1</code>, the <code>numElements</code> property
943         * is increased to <code>index +1</code> and additional storage is allocated
944         * (if necessary) for the new element and all  (uninitialized) elements
945         * between the new element and the previous end of the array).
946         *
947         * @param index index to store a value in
948         * @param value value to store at the specified index
949         * @throws ArrayIndexOutOfBoundsException if {@code index < 0}.
950         */
951        public synchronized void setElement(int index, double value) {
952            if (index < 0) {
953                throw new ArrayIndexOutOfBoundsException(index);
954            }
955            if (index + 1 > numElements) {
956                numElements = index + 1;
957            }
958            if ((startIndex + index) >= internalArray.length) {
959                expandTo(startIndex + (index + 1));
960            }
961            internalArray[startIndex + index] = value;
962        }
963
964        /**
965         * Sets the expansionFactor.  Throws IllegalArgumentException if the
966         * the following conditions are not met:
967         * <ul>
968         * <li><code>expansionFactor > 1</code></li>
969         * <li><code>contractionFactor >= expansionFactor</code></li>
970         * </ul>
971         * @param expansionFactor the new expansion factor value.
972         * @throws MathIllegalArgumentException if expansionFactor is <= 1 or greater
973         * than contractionFactor
974         * @deprecated As of 3.1 (to be removed in 4.0 as field will become "final").
975         */
976        @Deprecated
977        public void setExpansionFactor(float expansionFactor) throws MathIllegalArgumentException {
978            checkContractExpand(getContractionCriterion(), expansionFactor);
979            // The check above verifies that the expansion factor is > 1.0;
980            synchronized(this) {
981                this.expansionFactor = expansionFactor;
982            }
983        }
984
985        /**
986         * Sets the <code>expansionMode</code>. The specified value must be one of
987         * ADDITIVE_MODE, MULTIPLICATIVE_MODE.
988         *
989         * @param expansionMode The expansionMode to set.
990         * @throws MathIllegalArgumentException if the specified mode value is not valid.
991         * @deprecated As of 3.1. Please use {@link #setExpansionMode(ExpansionMode)} instead.
992         */
993        @Deprecated
994        public void setExpansionMode(int expansionMode)
995            throws MathIllegalArgumentException {
996            if (expansionMode != MULTIPLICATIVE_MODE &&
997                expansionMode != ADDITIVE_MODE) {
998                throw new MathIllegalArgumentException(LocalizedFormats.UNSUPPORTED_EXPANSION_MODE, expansionMode,
999                                                       MULTIPLICATIVE_MODE, "MULTIPLICATIVE_MODE",
1000                                                       ADDITIVE_MODE, "ADDITIVE_MODE");
1001            }
1002            synchronized(this) {
1003                if (expansionMode == MULTIPLICATIVE_MODE) {
1004                    setExpansionMode(ExpansionMode.MULTIPLICATIVE);
1005                } else if (expansionMode == ADDITIVE_MODE) {
1006                    setExpansionMode(ExpansionMode.ADDITIVE);
1007                }
1008            }
1009        }
1010
1011        /**
1012         * Sets the {@link ExpansionMode expansion mode}.
1013         *
1014         * @param expansionMode Expansion mode to use for resizing the array.
1015         * @deprecated As of 3.1 (to be removed in 4.0 as field will become "final").
1016         */
1017        @Deprecated
1018        public void setExpansionMode(ExpansionMode expansionMode) {
1019            this.expansionMode = expansionMode;
1020        }
1021
1022        /**
1023         * Sets the initial capacity.  Should only be invoked by constructors.
1024         *
1025         * @param initialCapacity of the array
1026         * @throws MathIllegalArgumentException if <code>initialCapacity</code> is not
1027         * positive.
1028         * @deprecated As of 3.1, this is a no-op.
1029         */
1030        @Deprecated
1031        protected void setInitialCapacity(int initialCapacity)
1032            throws MathIllegalArgumentException {
1033            // Body removed in 3.1.
1034        }
1035
1036        /**
1037         * This function allows you to control the number of elements contained
1038         * in this array, and can be used to "throw out" the last n values in an
1039         * array. This function will also expand the internal array as needed.
1040         *
1041         * @param i a new number of elements
1042         * @throws MathIllegalArgumentException if <code>i</code> is negative.
1043         */
1044        public synchronized void setNumElements(int i)
1045            throws MathIllegalArgumentException {
1046            // If index is negative thrown an error.
1047            if (i < 0) {
1048                throw new MathIllegalArgumentException(
1049                        LocalizedFormats.INDEX_NOT_POSITIVE,
1050                        i);
1051            }
1052
1053            // Test the new num elements, check to see if the array needs to be
1054            // expanded to accommodate this new number of elements.
1055            final int newSize = startIndex + i;
1056            if (newSize > internalArray.length) {
1057                expandTo(newSize);
1058            }
1059
1060            // Set the new number of elements to new value.
1061            numElements = i;
1062        }
1063
1064        /**
1065         * Returns true if the internal storage array has too many unused
1066         * storage positions.
1067         *
1068         * @return true if array satisfies the contraction criteria
1069         */
1070        private synchronized boolean shouldContract() {
1071            if (expansionMode == ExpansionMode.MULTIPLICATIVE) {
1072                return (internalArray.length / ((float) numElements)) > contractionCriterion;
1073            } else {
1074                return (internalArray.length - numElements) > contractionCriterion;
1075            }
1076        }
1077
1078        /**
1079         * Returns the starting index of the internal array.  The starting index is
1080         * the position of the first addressable element in the internal storage
1081         * array.  The addressable elements in the array are <code>
1082         * internalArray[startIndex],...,internalArray[startIndex + numElements -1]
1083         * </code>
1084         *
1085         * @return the starting index.
1086         * @deprecated As of 3.1.
1087         */
1088        @Deprecated
1089        public synchronized int start() {
1090            return startIndex;
1091        }
1092
1093        /**
1094         * <p>Copies source to dest, copying the underlying data, so dest is
1095         * a new, independent copy of source.  Does not contract before
1096         * the copy.</p>
1097         *
1098         * <p>Obtains synchronization locks on both source and dest
1099         * (in that order) before performing the copy.</p>
1100         *
1101         * <p>Neither source nor dest may be null; otherwise a {@link NullArgumentException}
1102         * is thrown</p>
1103         *
1104         * @param source ResizableDoubleArray to copy
1105         * @param dest ResizableArray to replace with a copy of the source array
1106         * @exception NullArgumentException if either source or dest is null
1107         * @since 2.0
1108         *
1109         */
1110        public static void copy(ResizableDoubleArray source,
1111                                ResizableDoubleArray dest)
1112            throws NullArgumentException {
1113            MathUtils.checkNotNull(source);
1114            MathUtils.checkNotNull(dest);
1115            synchronized(source) {
1116               synchronized(dest) {
1117                   dest.contractionCriterion = source.contractionCriterion;
1118                   dest.expansionFactor = source.expansionFactor;
1119                   dest.expansionMode = source.expansionMode;
1120                   dest.internalArray = new double[source.internalArray.length];
1121                   System.arraycopy(source.internalArray, 0, dest.internalArray,
1122                           0, dest.internalArray.length);
1123                   dest.numElements = source.numElements;
1124                   dest.startIndex = source.startIndex;
1125               }
1126           }
1127        }
1128
1129        /**
1130         * Returns a copy of the ResizableDoubleArray.  Does not contract before
1131         * the copy, so the returned object is an exact copy of this.
1132         *
1133         * @return a new ResizableDoubleArray with the same data and configuration
1134         * properties as this
1135         * @since 2.0
1136         */
1137        public synchronized ResizableDoubleArray copy() {
1138            final ResizableDoubleArray result = new ResizableDoubleArray();
1139            copy(this, result);
1140            return result;
1141        }
1142
1143        /**
1144         * Returns true iff object is a ResizableDoubleArray with the same properties
1145         * as this and an identical internal storage array.
1146         *
1147         * @param object object to be compared for equality with this
1148         * @return true iff object is a ResizableDoubleArray with the same data and
1149         * properties as this
1150         * @since 2.0
1151         */
1152        @Override
1153        public boolean equals(Object object) {
1154            if (object == this ) {
1155                return true;
1156            }
1157            if (object instanceof ResizableDoubleArray == false) {
1158                return false;
1159            }
1160            synchronized(this) {
1161                synchronized(object) {
1162                    boolean result = true;
1163                    final ResizableDoubleArray other = (ResizableDoubleArray) object;
1164                    result = result && (other.contractionCriterion == contractionCriterion);
1165                    result = result && (other.expansionFactor == expansionFactor);
1166                    result = result && (other.expansionMode == expansionMode);
1167                    result = result && (other.numElements == numElements);
1168                    result = result && (other.startIndex == startIndex);
1169                    if (!result) {
1170                        return false;
1171                    } else {
1172                        return Arrays.equals(internalArray, other.internalArray);
1173                    }
1174                }
1175            }
1176        }
1177
1178        /**
1179         * Returns a hash code consistent with equals.
1180         *
1181         * @return the hash code representing this {@code ResizableDoubleArray}.
1182         * @since 2.0
1183         */
1184        @Override
1185        public synchronized int hashCode() {
1186            final int[] hashData = new int[6];
1187            hashData[0] = Double.valueOf(expansionFactor).hashCode();
1188            hashData[1] = Double.valueOf(contractionCriterion).hashCode();
1189            hashData[2] = expansionMode.hashCode();
1190            hashData[3] = Arrays.hashCode(internalArray);
1191            hashData[4] = numElements;
1192            hashData[5] = startIndex;
1193            return Arrays.hashCode(hashData);
1194        }
1195
1196    }


text:
'use strict';

/**
 * Requirements
 */
const Documentation = require(ES_SOURCE + '/model/documentation/Documentation.js').Documentation;
const documentationShared = require('./DocumentationShared.js').spec;

/**
 * Spec
 */
describe(Documentation.className, function()
{
    documentationShared(Documentation, 'model.documentation/Documentation');
});