diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..73b3466faeb5ab7c0cc168aa4b7671dede5e1407 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.classpath +.project +coverage/ +dist/ +reports/ +bin/ +build/ +pom.xml +perf/ diff --git a/CHANGES b/CHANGES index 60a025969cdcff21e8e6f91aba168bded5aab47f..19e8512df74aea0713c0589bcd2db1dbd07a7644 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,21 @@ +2.6.17 + +- New FileLines*Iterable classes replacing older FileLines*Collection + implementations. It provides transparently support for more than 2^31 + line and arbitrary decompressors that extend java.io.InputStream. It + is also possible to specify the number of strings in advance. + +- New lexicographical prefix-free transformation strategy for byte + arrays that do not contain zeros. + +- Fixed problem with generation of Java 8 code and some ByteBuffer + methods. Thanks to Aaron Novstrup for reporting this bug. + +2.6.16 + +- The DSI Utilities are now dually licensed under the Lesser GNU Public + License 2.1+ or the Apache Software License 2.0. + 2.6.15 - Removed (almost) unused dependencies. diff --git a/COPYING b/COPYING deleted file mode 100644 index 94a9ed024d3859793618152ea559a168bbcbb5e2..0000000000000000000000000000000000000000 --- a/COPYING +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - <program> Copyright (C) <year> <name of author> - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -<http://www.gnu.org/licenses/>. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/COPYING.LESSER b/COPYING.LESSER index 65c5ca88a67c30becee01c5a8816d964b03862f9..4362b49151d7b34ef83b3067a8f9c9f877d72a0e 100644 --- a/COPYING.LESSER +++ b/COPYING.LESSER @@ -1,165 +1,502 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/LICENSE-2.0.txt b/LICENSE-2.0.txt new file mode 100644 index 0000000000000000000000000000000000000000..d645695673349e3947e8e5ae42332d0ac3164cd7 --- /dev/null +++ b/LICENSE-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ec7216caf3d825df26e0aabfaa01015308789a6c --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +Welcome to the DSI Utilities! +----------------------------- + +[The DSI Utilities](http://dsiutils.di.unimi.it/) are a mishmash of +classes accumulated during the last twenty years in projects developed at +the DSI (Dipartimento di Scienze dell'Informazione, i.e., Information +Sciences Department), now DI (Dipartimento di Informatica, i.e., +Informatics Department), of the Università degli Studi di Milano. + +seba (<mailto:sebastiano.vigna@unimi.it>) diff --git a/bash/maketable.sh b/bash/maketable.sh new file mode 100755 index 0000000000000000000000000000000000000000..c607a00cb11538f91a243d8987a09d0d51eb014e --- /dev/null +++ b/bash/maketable.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Takes the output of RandomSpeed and generates lines for an HTML table + +repeats=4 +numgens=5 + +tot=$(grep "ThreadLocalRandom.next" $1 | cut -d. -f2 | wc -l) +n=$((tot/repeats)) + +paste <(for((i=0; i<n; i++)); do echo " * <TR><TD>"; done) \ + <(grep "ThreadLocalRandom.next" $1 | cut -d. -f3 | tail -n $n) \ + <(egrep -o "[0-9.]+ ns" $1 | cut -d' ' -f1 | tail -n $((n*numgens)) | awk "{ printf(\"<TD>%s\", \$0); i = i + 1; if ( i % $numgens == 0 ) printf \"\\n\"; }") diff --git a/bash/maketablejmh.sh b/bash/maketablejmh.sh new file mode 100755 index 0000000000000000000000000000000000000000..15b89f411549422892d4a20e4a2dc7394e42d471 --- /dev/null +++ b/bash/maketablejmh.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# for m in nextInt nextLong nextDouble nextInt100000 nextInt229228 nextInt230 nextInt2301 nextInt230229 nextLong1000000000000 nextLong2621; do +for m in nextLong nextInt100000 nextDouble; do + for r in Random ThreadLocalRandom SplittableRandom SplitMix64 XoRoShiRo128PlusPlus XoRoShiRo128StarStar XoRoShiRo128Plus XoShiRo256PlusPlus XoShiRo256StarStar XoShiRo256Plus XorShift1024StarPhi; do + v=$(grep ^Benchmark$r.$m\ $1 | tr -s ' ' | cut -d' ' -f4) + r=$(grep ^Benchmark$r.$m\ $1 | tr -s ' ' | cut -d' ' -f6) + echo -n "<TD STYLE='text-align: right'>$(echo $v-$r-1 | bc -l)" + done + echo +done diff --git a/bash/permbfcl.sh b/bash/permbfcl.sh new file mode 100755 index 0000000000000000000000000000000000000000..a8ce39919d788c4ea7473c4eb827694c72551856 --- /dev/null +++ b/bash/permbfcl.sh @@ -0,0 +1,16 @@ +#!/bin/bash -ex + +if [[ "$@" == "" ]]; then + echo "USAGE: $(basename $0) FCL" 1>&2 + echo "The list of string will be read from standard input in UTF-8 encoding." 1>&2 + exit 1 +fi + +PERM=$(mktemp) +LEXFCL=$(mktemp) + +nl -v0 -nln | LC_ALL=C sort -S2G -T. -k2 | tee >(cut -f1 | tr -d ' ' >$PERM) | cut -f2 | java -server it.unimi.dsi.big.util.FrontCodedStringBigList -u $LEXFCL + +java -server it.unimi.dsi.big.util.PermutedFrontCodedStringBigList -i -t $LEXFCL $PERM $1 + +rm -f $LEXFCL $PERM diff --git a/bash/permfcl.sh b/bash/permfcl.sh new file mode 100755 index 0000000000000000000000000000000000000000..1ab9738dc101793d68eeac7985d547f7bb539a64 --- /dev/null +++ b/bash/permfcl.sh @@ -0,0 +1,16 @@ +#!/bin/bash -e + +if [[ "$@" == "" ]]; then + echo "USAGE: $(basename $0) FCL" 1>&2 + echo "The list of string will be read from standard input in UTF-8 encoding." 1>&2 + exit 1 +fi + +PERM=$(mktemp) +LEXFCL=$(mktemp) + +nl -v0 -nln | LC_ALL=C sort -S2G -T. -k2 | tee >(cut -f1 | tr -d ' ' >$PERM) | cut -f2 | java -server it.unimi.dsi.util.FrontCodedStringList -u $LEXFCL + +java -server it.unimi.dsi.util.PermutedFrontCodedStringList -i -t $LEXFCL $PERM $1 + +rm -f $LEXFCL $PERM diff --git a/build.properties b/build.properties index bf4c78b3883ceb23f8e2abebf293bb429da25395..46eb7dbfc4efb12525ffafad30d0bf94dfd18345 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ -version=2.6.15 +version=2.6.17 build.sysclasspath=ignore @@ -27,4 +27,4 @@ commons-io.apiurl=http://commons.apache.org/proper/commons-io/javadocs/api-relea commons-lang3.apiurl=http://commons.apache.org/proper/commons-lang/javadocs/api-release/ commons-collections4.apiurl=https://commons.apache.org/proper/commons-collections/javadocs/api-4.4/ commons-math3.apiurl=https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/ -guava.apiurl=https://guava.dev/releases/26.0-jre/api/docs/ +guava.apiurl=https://javadoc.io/doc/com.google.guava/guava/latest/index.html diff --git a/build.xml b/build.xml index 0078ea404f673eb74914e38863fd5e776918bc08..7624ef6149d32a1f611b596b02fe1d8cd36a8e5b 100644 --- a/build.xml +++ b/build.xml @@ -81,7 +81,7 @@ <!-- build the sources artifact --> <jar jarfile="${maven-sources-jar}"> - <fileset dir="." includes="CHANGES,COPYING,COPYING.LESSER,dsiutils.bnd,build.xml,build.properties,ivy.xml,${src}/**/*.java,${src}/**/*.12,${src}/**/*.16,${src}/**/*.html,${test}/**/*.java,${slow}/**/*.java"/> + <fileset dir="." includes="README.md,CHANGES,COPYING.LESSER,LICENSE-2.0.txt,dsiutils.bnd,build.xml,build.properties,ivy.xml,${src}/**/*.java,${src}/**/*.12,${src}/**/*.16,${src}/**/*.html,${test}/**/*.java,${slow}/**/*.java"/> </jar> </target> @@ -146,7 +146,7 @@ </target> <target name="compile" depends="init" description="Compile sources (without tests)"> - <javac srcdir="${src}" debug="on" optimize="on" destdir="${build}" encoding="UTF-8" source="1.8" target="1.8" classpathref="compile.classpath"> + <javac srcdir="${src}" debug="on" optimize="on" destdir="${build}" encoding="UTF-8" release="8" classpathref="compile.classpath"> <compilerarg value="-Xlint:all"/> </javac> <copy todir="${build}"> @@ -156,7 +156,7 @@ </target> <target name="compile-tests" depends="init" description="Compile sources (with tests)"> - <javac srcdir="${src}:${test}:${slow}" debug="on" optimize="on" destdir="${build}" encoding="UTF-8" source="1.8" target="1.8" classpathref="test.classpath"> + <javac srcdir="${src}:${test}:${slow}" debug="on" optimize="on" destdir="${build}" encoding="UTF-8" release="8" classpathref="test.classpath"> <compilerarg value="-Xlint:all"/> </javac> <copy todir="${build}"> @@ -193,6 +193,7 @@ overview="${src}/overview.html" source="1.8" windowtitle="dsiutil ${version}" + additionalparam="-breakiterator -tag "apiNote:a:API Notes:" -tag "implSpec:a:Implementation Specification:" -tag "implNote:a:Implementation Notes:\"" classpathref="compile.classpath"> <link href="${j2se.apiurl}"/> <link href="${fastutil.apiurl}"/> diff --git a/ivy.xml b/ivy.xml index 9e6ccb91b9afa2fc2e5546d068f83f7fad840e42..1f14170daa7ecc607722d30a274e03f2a189d311 100644 --- a/ivy.xml +++ b/ivy.xml @@ -15,18 +15,17 @@ <dependencies> <dependency org="it.unimi.dsi" name="fastutil" rev="latest.release" /> - <dependency org="com.martiansoftware" name="jsap" rev="latest.release"/> + <dependency org="it.unimi.di" name="jsap" rev="20210129"/> <dependency org="junit" name="junit" rev="latest.release" conf="test"/> - + <dependency org="org.apache.commons" name="commons-configuration2" rev="latest.release"/> + <dependency org="org.apache.commons" name="commons-math3" rev="latest.release"/> <dependency org="com.google.guava" name="guava" rev="latest.release"/> - <dependency org="org.slf4j" name="slf4j-api" rev="1.7.30" force="true"/> + <dependency org="ch.qos.logback" name="logback-core" rev="1.2.3" conf="runtime" force="true"/> <dependency org="ch.qos.logback" name="logback-classic" rev="1.2.3" conf="runtime" force="true"/> - <dependency org="org.apache.commons" name="commons-configuration2" rev="latest.release"/> - <dependency org="org.apache.commons" name="commons-math3" rev="latest.release"/> - <dependency org="org.apache.commons" name="commons-io" rev="latest.release" conf="test"/> <dependency org="org.apache.commons" name="commons-collections4" rev="latest.release" conf="test"/> + <dependency org="com.github.luben" name="zstd-jni" rev="latest.release" conf="test"/> </dependencies> </ivy-module> diff --git a/makefile b/makefile new file mode 100644 index 0000000000000000000000000000000000000000..2ff85f585044cb06a024d2aea32e1a3050f3b18b --- /dev/null +++ b/makefile @@ -0,0 +1,49 @@ +include build.properties + +TAR=tar + +source: + rm -fr dsiutils-$(version) + ant clean + ln -s . dsiutils-$(version) + $(TAR) chvf dsiutils-$(version)-src.tar --owner=0 --group=0 \ + dsiutils-$(version)/README.md \ + dsiutils-$(version)/CHANGES \ + dsiutils-$(version)/COPYING.LESSER \ + dsiutils-$(version)/LICENSE-2.0.txt \ + dsiutils-$(version)/build.xml \ + dsiutils-$(version)/ivy.xml \ + dsiutils-$(version)/dsiutils.bnd \ + dsiutils-$(version)/pom-model.xml \ + dsiutils-$(version)/build.properties \ + $$(find dsiutils-$(version)/src/it/unimi/dsi -iname \*.java -or -iname \*.html -or -iname \*.in.16 -or -iname \*.out.12) \ + $$(find dsiutils-$(version)/test/it/unimi/dsi -iname \*.java -or -iname \*.html -or -iname \*.data) \ + $$(find dsiutils-$(version)/slow/it/unimi/dsi -iname \*.java -or -iname \*.html) \ + dsiutils-$(version)/src/overview.html + $(TAR) --delete --wildcards -v -f dsiutils-$(version)-src.tar \ + dsiutils-$(version)/src/it/unimi/dsi/test/*.java \ + dsiutils-$(version)/test/it/unimi/dsi/test/*.java \ + dsiutils-$(version)/src/it/unimi/dsi/util/IntParallel*.java \ + dsiutils-$(version)/src/it/unimi/dsi/util/XorGens*.java \ + dsiutils-$(version)/src/it/unimi/dsi/stat/Ziggurat.java + gzip -f dsiutils-$(version)-src.tar + rm dsiutils-$(version) + +binary: + rm -fr dsiutils-$(version) + $(TAR) zxvf dsiutils-$(version)-src.tar.gz + (cd dsiutils-$(version) && unset CLASSPATH && unset LOCAL_IVY_SETTINGS && ant ivy-clean ivy-setupjars && ant junit && ant clean && ant jar javadoc) + $(TAR) zcvf dsiutils-$(version)-bin.tar.gz --owner=0 --group=0 \ + dsiutils-$(version)/README.md \ + dsiutils-$(version)/CHANGES \ + dsiutils-$(version)/COPYING.LESSER \ + dsiutils-$(version)/LICENSE-2.0.txt \ + dsiutils-$(version)/dsiutils-$(version).jar \ + dsiutils-$(version)/docs + $(TAR) zcvf dsiutils-$(version)-deps.tar.gz --owner=0 --group=0 --transform='s|.*/||' $$(find dsiutils-$(version)/jars/runtime -iname \*.jar -exec readlink {} \;) + +stage: + rm -fr dsiutils-$(version) + $(TAR) zxvf dsiutils-$(version)-src.tar.gz + cp -fr bnd dsiutils-$(version) + (cd dsiutils-$(version) && unset CLASSPATH && unset LOCAL_IVY_SETTINGS && ant ivy-clean ivy-setupjars && ant stage) diff --git a/pom-model.xml b/pom-model.xml index 138041bacd13c2060f08e5bc41f5ae5087c65b4d..157034929046775ff2f5562f49d7d0eac365c7a5 100644 --- a/pom-model.xml +++ b/pom-model.xml @@ -5,18 +5,23 @@ <packaging>jar</packaging> <name>DSI Utilities</name> <version>${ivy.pom.version}</version> - <description>The DSI utilities are a mish mash of classes accumulated during the last ten years in projects developed at the DSI (Dipartimento di Scienze dell'Informazione, i.e., Information Sciences Department), now DI (Dipartimento di Informatica, i.e., Informatics Department), of the Universita` degli Studi di Milano.</description> + <description>The DSI utilities are a mishmash of classes accumulated during the last twenty years in projects developed at the DSI (Dipartimento di Scienze dell'Informazione, i.e., Information Sciences Department), now DI (Dipartimento di Informatica, i.e., Informatics Department), of the Universita` degli Studi di Milano.</description> <url>http://dsiutils.di.unimi.it/</url> <licenses> <license> - <name>GNU Lesser General Public License Version 3+</name> - <url>http://www.gnu.org/licenses/lgpl.html</url> + <name>GNU Lesser General Public License Version 2.1+</name> + <url>https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</url> <distribution>repo</distribution> </license> + <license> + <name>Apache License v2.0</name> + <url>https://www.apache.org/licenses/LICENSE-2.0</url> + <distribution>source</distribution> + </license> </licenses> <scm> - <connection>scm:git://github.com/vigna/DSI-Utilities.git</connection> - <url>https://github.com/vigna/DSI-Utilities</url> + <connection>scm:git://github.com/vigna/dsiutils.git</connection> + <url>https://github.com/vigna/dsiutils</url> </scm> <developers> <developer> diff --git a/setcp.sh b/setcp.sh new file mode 100755 index 0000000000000000000000000000000000000000..f0f88efbdc8eb7a9cfdca1d01f64e73c4995559f --- /dev/null +++ b/setcp.sh @@ -0,0 +1,18 @@ +JAR=dsiutils + +sourcedir=$(cd $(dirname ${BASH_ARGV[0]}) && pwd) +count=$(\ls -1 $sourcedir/$JAR-*.jar 2>/dev/null | wc -l) + +if (( count == 0 )); then + echo "WARNING: no $JAR jar file." +elif (( count > 1 )); then + echo "WARNING: several $JAR jar files ($(\ls -m $JAR-*.jar))" +else + if echo $CLASSPATH | grep -q slf4j; then + deps=$(\ls -1 $sourcedir/jars/test/*.jar | grep -v slf4j | paste -d: -s) + else + deps=$(\ls -1 $sourcedir/jars/test/*.jar | paste -d: -s) + fi + + export CLASSPATH=$(ls -1 $sourcedir/$JAR-*.jar | tail -n 1):$deps:$CLASSPATH +fi diff --git a/slow/it/unimi/dsi/big/util/ImmutableExternalPrefixMapSlowTest.java b/slow/it/unimi/dsi/big/util/ImmutableExternalPrefixMapSlowTest.java index 3930db6488783c6f4db8290a87e1e84ce41b0f47..4f3b0a40e7818261cca2628f420639af56527f02 100644 --- a/slow/it/unimi/dsi/big/util/ImmutableExternalPrefixMapSlowTest.java +++ b/slow/it/unimi/dsi/big/util/ImmutableExternalPrefixMapSlowTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/Util.java b/src/it/unimi/dsi/Util.java index f163f7549ef10caadc6e112eab1ef3d6421b5bf0..4ddd4f701bdcb18430f6e21de661c362a60e8e18 100644 --- a/src/it/unimi/dsi/Util.java +++ b/src/it/unimi/dsi/Util.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi; diff --git a/src/it/unimi/dsi/big/io/FileLinesByteArrayCollection.java b/src/it/unimi/dsi/big/io/FileLinesByteArrayCollection.java index dbc8d7139c172f9e91497e5e6f9c3aa747e76c41..05df13625c9a08b4e0abfbf9b9a34000b7d7c434 100644 --- a/src/it/unimi/dsi/big/io/FileLinesByteArrayCollection.java +++ b/src/it/unimi/dsi/big/io/FileLinesByteArrayCollection.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.io; @@ -36,30 +35,40 @@ import it.unimi.dsi.fastutil.io.FastBufferedInputStream; import it.unimi.dsi.fastutil.io.FastBufferedInputStream.LineTerminator; import it.unimi.dsi.fastutil.objects.ObjectBigArrayBigList; import it.unimi.dsi.fastutil.objects.ObjectBigList; +import it.unimi.dsi.io.FileLinesByteArrayIterable; import it.unimi.dsi.io.SafelyCloseable; -/** A wrapper exhibiting the lines of a file as a {@link java.util.Collection} of byte arrays. +/** + * A wrapper exhibiting the lines of a file as a {@link java.util.Collection} of byte arrays. * - * <P>An instance of this class allows to access the lines of a file as a - * {@link java.util.Collection} of byte arrays. Reading is performed using + * <P> + * An instance of this class allows to access the lines of a file as a {@link java.util.Collection} + * of byte arrays. Reading is performed using * {@link FastBufferedInputStream#readLine(byte[], EnumSet)}, and follows the rules defined therein. * No decoding is performed. * - * <p>Using {@linkplain java.util.Collection#contains(java.lang.Object) - * direct access} is strongly discouraged (it will require a full scan of the file), but - * the {@link #iterator()} can be fruitfully used to scan the file, and can be called any - * number of times, as it opens an independent input stream at each call. For the - * same reason, the returned iterator type ({@link it.unimi.dsi.io.FileLinesCollection.FileLinesIterator}) - * is {@link java.io.Closeable}, and should be closed after usage. + * <p> + * Using {@linkplain java.util.Collection#contains(java.lang.Object) direct access} is strongly + * discouraged (it will require a full scan of the file), but the {@link #iterator()} can be + * fruitfully used to scan the file, and can be called any number of times, as it opens an + * independent input stream at each call. For the same reason, the returned iterator type + * ({@link it.unimi.dsi.io.FileLinesCollection.FileLinesIterator}) is {@link java.io.Closeable}, and + * should be closed after usage. * - * <p>Using a suitable {@linkplain #FileLinesByteArrayCollection(CharSequence, boolean, EnumSet) constructor}, it is possible - * to specify that the file is compressed in <code>gzip</code> format (in this case, it will be opened using a {@link GZIPInputStream}). + * <p> + * Using a suitable {@linkplain #FileLinesByteArrayCollection(CharSequence, boolean, EnumSet) + * constructor}, it is possible to specify that the file is compressed in <code>gzip</code> format + * (in this case, it will be opened using a {@link GZIPInputStream}). * - * <P>Note that the first call to {@link #size64()} will require a full file scan. + * <P> + * Note that the first call to {@link #size64()} will require a full file scan. * * @author Sebastiano Vigna * @since 2.2.8 + * @deprecated Please use {@link FileLinesByteArrayIterable} instead; the {@code zipped} option of + * this class can be simulated by passing a {@link GZIPInputStream} as decompressor. */ +@Deprecated public class FileLinesByteArrayCollection extends AbstractCollection<byte[]> implements Size64 { /** The filename upon which this file-lines collection is based. */ private final String filename; @@ -102,13 +111,22 @@ public class FileLinesByteArrayCollection extends AbstractCollection<byte[]> imp } - /** An iterator over the lines of a {@link FileLinesByteArrayCollection}. + /** + * An iterator over the lines of a {@link FileLinesByteArrayCollection}. + * + * <p> + * Instances of this class open an {@link java.io.InputStream}, and thus should be + * {@linkplain Closeable#close() closed} after usage. A “safety-net” finaliser tries to + * take care of the cases in which closing an instance is impossible. An exhausted iterator, + * however, will be closed automagically. * - * <p>Instances of this class open an {@link java.io.InputStream}, and thus should be {@linkplain Closeable#close() closed} after - * usage. A “safety-net” finaliser tries to take care of the cases in which - * closing an instance is impossible. An exhausted iterator, however, will be closed automagically. + * @deprecated Please use + * {@link FileLinesByteArrayIterable#iterator(java.io.InputStream, Class, EnumSet)}; the + * {@code zipped} option of this class can be simulated by passing a + * {@link GZIPInputStream} as decompressor. */ + @Deprecated public static final class FileLinesIterator implements Iterator<byte[]>, SafelyCloseable { private FastBufferedInputStream fbis; byte[] buffer = new byte[1024]; @@ -172,7 +190,6 @@ public class FileLinesByteArrayCollection extends AbstractCollection<byte[]> imp } } - @SuppressWarnings("deprecation") @Override protected synchronized void finalize() throws Throwable { try { diff --git a/src/it/unimi/dsi/big/io/FileLinesCollection.java b/src/it/unimi/dsi/big/io/FileLinesCollection.java index 231934ee9caf1eb92ca5adfedcc9882080ac750f..0b359818a981bf49d6e9d959f7b89d9c730315fc 100644 --- a/src/it/unimi/dsi/big/io/FileLinesCollection.java +++ b/src/it/unimi/dsi/big/io/FileLinesCollection.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.io; @@ -34,40 +33,52 @@ import it.unimi.dsi.fastutil.Size64; import it.unimi.dsi.fastutil.objects.ObjectBigArrayBigList; import it.unimi.dsi.fastutil.objects.ObjectBigList; import it.unimi.dsi.io.FastBufferedReader; +import it.unimi.dsi.io.FileLinesMutableStringIterable; import it.unimi.dsi.io.SafelyCloseable; import it.unimi.dsi.lang.MutableString; -/** A wrapper exhibiting the lines of a file as a {@link java.util.Collection}. +/** + * A wrapper exhibiting the lines of a file as a {@link java.util.Collection}. + * + * <P> + * <strong>Warning</strong>: the lines returned by iterators generated by instances of this class + * <em>are not cacheable</em>. The returned value is a {@link it.unimi.dsi.lang.MutableString} + * instance that is reused at each call, and that is <em>modified by a call to + * {@link java.util.Iterator#hasNext() hasNext()}</em>. Thus, for instance, * - * <P><strong>Warning</strong>: the lines returned by iterators generated by - * instances of this class <em>are not cacheable</em>. The returned value is - * a {@link it.unimi.dsi.lang.MutableString} instance that is reused - * at each call, and that is <em>modified by a call to {@link java.util.Iterator#hasNext() hasNext()}</em>. - * Thus, for instance, * <pre> - * ObjectIterators.unwrap(fileLinesColletion.iterator()); + * ObjectIterators.unwrap(fileLinesColletion.iterator()); * </pre> - * will not give the expected results. Use {@link #allLines()} to get - * the {@linkplain ObjectBigList big list} of all lines (again, under the form of compact {@link it.unimi.dsi.lang.MutableString}s). - * Note also that {@link #toString()} will return a single string containing all - * file lines separated by the string associated with the system property <code>line.separator</code>. * - * <P>An instance of this class allows to access the lines of a file as a - * {@link java.util.Collection}. Using {@linkplain java.util.Collection#contains(java.lang.Object) - * direct access} is strongly discouraged (it will require a full scan of the file), but - * the {@link #iterator()} can be fruitfully used to scan the file, and can be called any - * number of times, as it opens an independent input stream at each call. For the - * same reason, the returned iterator type ({@link it.unimi.dsi.io.FileLinesCollection.FileLinesIterator}) - * is {@link java.io.Closeable}, and should be closed after usage. + * will not give the expected results. Use {@link #allLines()} to get the {@linkplain ObjectBigList + * big list} of all lines (again, under the form of compact + * {@link it.unimi.dsi.lang.MutableString}s). Note also that {@link #toString()} will return a + * single string containing all file lines separated by the string associated with the system + * property <code>line.separator</code>. + * + * <P> + * An instance of this class allows to access the lines of a file as a {@link java.util.Collection}. + * Using {@linkplain java.util.Collection#contains(java.lang.Object) direct access} is strongly + * discouraged (it will require a full scan of the file), but the {@link #iterator()} can be + * fruitfully used to scan the file, and can be called any number of times, as it opens an + * independent input stream at each call. For the same reason, the returned iterator type + * ({@link it.unimi.dsi.io.FileLinesCollection.FileLinesIterator}) is {@link java.io.Closeable}, and + * should be closed after usage. * - * <p>Using a suitable {@linkplain #FileLinesCollection(CharSequence, String, boolean) constructor}, it is possible - * to specify that the file is compressed in <code>gzip</code> format (in this case, it will be opened using a {@link GZIPInputStream}). + * <p> + * Using a suitable {@linkplain #FileLinesCollection(CharSequence, String, boolean) constructor}, it + * is possible to specify that the file is compressed in <code>gzip</code> format (in this case, it + * will be opened using a {@link GZIPInputStream}). * - * <P>Note that the first call to {@link #size64()} will require a full file scan. + * <P> + * Note that the first call to {@link #size64()} will require a full file scan. * * @author Sebastiano Vigna * @since 2.0 + * @deprecated Please use {@link FileLinesMutableStringIterable} instead; the {@code zipped} option of this class + * can be simulated by passing a {@link GZIPInputStream} as decompressor. */ +@Deprecated public class FileLinesCollection extends AbstractCollection<MutableString> implements Size64 { /** The filename upon which this file-lines collection is based. */ private final String filename; @@ -101,13 +112,22 @@ public class FileLinesCollection extends AbstractCollection<MutableString> imple } - /** An iterator over the lines of a {@link FileLinesCollection}. + /** + * An iterator over the lines of a {@link FileLinesCollection}. * - * <p>Instances of this class open an {@link java.io.InputStream}, and thus should be {@linkplain Closeable#close() closed} after - * usage. A “safety-net” finaliser tries to take care of the cases in which - * closing an instance is impossible. An exhausted iterator, however, will be closed automagically. + * <p> + * Instances of this class open an {@link java.io.InputStream}, and thus should be + * {@linkplain Closeable#close() closed} after usage. A “safety-net” finaliser tries to + * take care of the cases in which closing an instance is impossible. An exhausted iterator, + * however, will be closed automagically. + * + * @deprecated Please use + * {@link FileLinesMutableStringIterable#iterator(java.io.InputStream, java.nio.charset.Charset, Class)}; + * the {@code zipped} option of this class can be simulated by passing a + * {@link GZIPInputStream} as decompressor. */ + @Deprecated public static final class FileLinesIterator implements Iterator<MutableString>, SafelyCloseable { private FastBufferedReader fbr; MutableString s = new MutableString(), next; @@ -160,7 +180,6 @@ public class FileLinesCollection extends AbstractCollection<MutableString> imple } } - @SuppressWarnings("deprecation") @Override protected synchronized void finalize() throws Throwable { try { diff --git a/src/it/unimi/dsi/big/io/package-info.java b/src/it/unimi/dsi/big/io/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..583f93856f06ad8cb90472a0b271aafc92c02b3c --- /dev/null +++ b/src/it/unimi/dsi/big/io/package-info.java @@ -0,0 +1,6 @@ +/** I/O big classes + * + * <p>Classes in this package are big versions of classes in {@link it.unimi.dsi.io}. + */ + +package it.unimi.dsi.big.io; diff --git a/src/it/unimi/dsi/big/io/package.html b/src/it/unimi/dsi/big/io/package.html deleted file mode 100644 index cc00b85d15086ffbf55ecf95520e8c67f108f328..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/big/io/package.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>I/O big classes</title> - </head> - - <body> - - <P>I/O big classes. - - <h2>Package Specification</h2> - - <p>Classes in this package are big versions of classes in {@link it.unimi.dsi.io}. - </body> -</html> diff --git a/src/it/unimi/dsi/big/util/AbstractPrefixMap.java b/src/it/unimi/dsi/big/util/AbstractPrefixMap.java index ff44ce714ff4743dc3c52b4ec0e724e1235da1a4..e3dab0aa25d368bf42a9681161181b718ce7fc23 100644 --- a/src/it/unimi/dsi/big/util/AbstractPrefixMap.java +++ b/src/it/unimi/dsi/big/util/AbstractPrefixMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/FrontCodedStringBigList.java b/src/it/unimi/dsi/big/util/FrontCodedStringBigList.java index 795431611751d5aa0d5267ca5bf21d766f490a0f..d8c8670e6d9363248ec1c5e63f3dc2f4394586cb 100644 --- a/src/it/unimi/dsi/big/util/FrontCodedStringBigList.java +++ b/src/it/unimi/dsi/big/util/FrontCodedStringBigList.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/ImmutableBinaryTrie.java b/src/it/unimi/dsi/big/util/ImmutableBinaryTrie.java index fc26d07e78610d0f7916abb10f304788febeb9ee..69bbf84ae03d401a95f1b17af322eff5a3721752 100644 --- a/src/it/unimi/dsi/big/util/ImmutableBinaryTrie.java +++ b/src/it/unimi/dsi/big/util/ImmutableBinaryTrie.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/ImmutableExternalPrefixMap.java b/src/it/unimi/dsi/big/util/ImmutableExternalPrefixMap.java index 42efe40d6217603df1f0e10514050a116ab6d622..c164efa1e595461efbcdc0aaf2713926580b387c 100644 --- a/src/it/unimi/dsi/big/util/ImmutableExternalPrefixMap.java +++ b/src/it/unimi/dsi/big/util/ImmutableExternalPrefixMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; @@ -25,13 +24,12 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStreamReader; +import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.nio.charset.Charset; import java.util.Arrays; -import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; @@ -60,8 +58,7 @@ import it.unimi.dsi.fastutil.io.BinIO; import it.unimi.dsi.fastutil.longs.LongBigArrayBigList; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectIterator; -import it.unimi.dsi.io.FastBufferedReader; -import it.unimi.dsi.io.FileLinesCollection; +import it.unimi.dsi.io.FileLinesMutableStringIterable; import it.unimi.dsi.io.InputBitStream; import it.unimi.dsi.io.OutputBitStream; import it.unimi.dsi.lang.MutableString; @@ -114,12 +111,16 @@ public class ImmutableExternalPrefixMap extends AbstractPrefixMap implements Ser /** A reference to the dump stream. */ protected transient InputBitStream dumpStream; - /** Creates an external prefix map with specified block size and dump stream. + /** + * Creates an external prefix map with specified block size and dump stream. * - * <P>This constructor does not assume that {@link CharSequence} instances returned by <code>terms.iterator()</code> - * will be distinct. Thus, it can be safely used with {@link FileLinesCollection}. + * <P> + * This constructor does not assume that {@link CharSequence} instances returned by + * <code>terms.iterator()</code> will be distinct. Thus, it can be safely used with + * {@link FileLinesMutableStringIterable}. * - * @param terms an iterable whose iterator will enumerate in lexicographical order the terms for the map. + * @param terms an iterable whose iterator will enumerate in lexicographical order the terms for the + * map. * @param blockSizeInBytes the block size (in bytes). * @param dumpStreamFilename the name of the dump stream, or {@code null} for a self-contained map. */ @@ -281,12 +282,16 @@ public class ImmutableExternalPrefixMap extends AbstractPrefixMap implements Ser dumpStream = new InputBitStream(tempDumpStreamFilename, blockSizeInBytes); } - /** Creates an external prefix map with block size {@link #STD_BLOCK_SIZE} and specified dump stream. + /** + * Creates an external prefix map with block size {@link #STD_BLOCK_SIZE} and specified dump stream. * - * <P>This constructor does not assume that {@link CharSequence} instances returned by <code>terms.iterator()</code> - * will be distinct. Thus, it can be safely used with {@link FileLinesCollection}. + * <P> + * This constructor does not assume that {@link CharSequence} instances returned by + * <code>terms.iterator()</code> will be distinct. Thus, it can be safely used with + * {@link FileLinesMutableStringIterable}. * - * @param terms a collection whose iterator will enumerate in lexicographical order the terms for the map. + * @param terms a collection whose iterator will enumerate in lexicographical order the terms for + * the map. * @param dumpStreamFilename the name of the dump stream, or {@code null} for a self-contained map. */ @@ -294,25 +299,32 @@ public class ImmutableExternalPrefixMap extends AbstractPrefixMap implements Ser this(terms, STD_BLOCK_SIZE, dumpStreamFilename); } - /** Creates an external prefix map with specified block size. + /** + * Creates an external prefix map with specified block size. * - * <P>This constructor does not assume that {@link CharSequence} instances returned by <code>terms.iterator()</code> - * will be distinct. Thus, it can be safely used with {@link FileLinesCollection}. + * <P> + * This constructor does not assume that {@link CharSequence} instances returned by + * <code>terms.iterator()</code> will be distinct. Thus, it can be safely used with + * {@link FileLinesMutableStringIterable}. * * @param blockSizeInBytes the block size (in bytes). - * @param terms a collection whose iterator will enumerate in lexicographical order the terms for the map. + * @param terms a collection whose iterator will enumerate in lexicographical order the terms for + * the map. */ public ImmutableExternalPrefixMap(final Iterable<? extends CharSequence> terms, final int blockSizeInBytes) throws IOException { this(terms, blockSizeInBytes, null); } - /** Creates an external prefix map with block size {@link #STD_BLOCK_SIZE}. + /** + * Creates an external prefix map with block size {@link #STD_BLOCK_SIZE}. * - * <P>This constructor does not assume that strings returned by <code>terms.iterator()</code> - * will be distinct. Thus, it can be safely used with {@link FileLinesCollection}. + * <P> + * This constructor does not assume that strings returned by <code>terms.iterator()</code> will be + * distinct. Thus, it can be safely used with {@link FileLinesMutableStringIterable}. * - * @param terms a collection whose iterator will enumerate in lexicographical order the terms for the map. + * @param terms a collection whose iterator will enumerate in lexicographical order the terms for + * the map. */ public ImmutableExternalPrefixMap(final Iterable<? extends CharSequence> terms) throws IOException { @@ -648,44 +660,38 @@ public class ImmutableExternalPrefixMap extends AbstractPrefixMap implements Ser @SuppressWarnings("unchecked") public static void main(final String[] arg) throws ClassNotFoundException, IOException, JSAPException, SecurityException, NoSuchMethodException { - final SimpleJSAP jsap = new SimpleJSAP(ImmutableExternalPrefixMap.class.getName(), - "Builds an external prefix map reading from standard input a newline-separated list of sorted terms or a serialised term list. If the dump stream name is not specified, the map will be self-contained.\n\n" + - "Note that if you read terms from stdin or from a serialized object all terms will have to be loaded in memory.", - new Parameter[] { - new FlaggedOption("blockSize", JSAP.INTSIZE_PARSER, (STD_BLOCK_SIZE / 1024) + "Ki", JSAP.NOT_REQUIRED, 'b', "block-size", "The size of a block in the dump stream."), - new Switch("serialised", 's', "serialised", "The data source (file or standard input) provides a serialised java.util.List of terms."), - new Switch("zipped", 'z', "zipped", "Standard input is compressed in gzip format."), - new FlaggedOption("termFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "offline", "Read terms from this file instead of standard input."), - new FlaggedOption("encoding", ForNameStringParser.getParser(Charset.class), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term list encoding."), - new UnflaggedOption("map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised map."), - new UnflaggedOption("dump", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "An optional dump stream (the resulting map will not be self-contained).") - } - ); + final SimpleJSAP jsap = new SimpleJSAP(ImmutableExternalPrefixMap.class.getName(), "Builds an external prefix map reading from standard input a newline-separated list of sorted terms or a serialised term list. If the dump stream name is not specified, the map will be self-contained.\n\n" + "Note that if you read terms from stdin or from a serialized object all terms will have to be loaded in memory.", new Parameter[] { + new FlaggedOption("blockSize", JSAP.INTSIZE_PARSER, (STD_BLOCK_SIZE / 1024) + "Ki", JSAP.NOT_REQUIRED, 'b', "block-size", "The size of a block in the dump stream."), + new Switch("serialised", 's', "serialised", "The data source (file or standard input) provides a serialised java.util.List of terms."), + new Switch("zipped", 'z', "zipped", "The term list is compressed in gzip format."), + new FlaggedOption("decompressor", JSAP.CLASS_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'd', "decompressor", "Use this extension of InputStream to decompress the terms."), + new FlaggedOption("termFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "offline", "Read terms from this file instead of standard input."), + new FlaggedOption("encoding", ForNameStringParser.getParser(Charset.class), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term list encoding."), + new UnflaggedOption("map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised map."), + new UnflaggedOption("dump", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "An optional dump stream (the resulting map will not be self-contained).") }); final JSAPResult jsapResult = jsap.parse(arg); if (jsap.messagePrinted()) return; - Collection<? extends CharSequence> termList; + Iterable<? extends CharSequence> termList; final String termFile = jsapResult.getString("termFile"); final Charset encoding = (Charset)jsapResult.getObject("encoding"); final boolean zipped = jsapResult.getBoolean("zipped"); + Class<? extends InputStream> decompressor = jsapResult.getClass("decompressor"); final boolean serialised = jsapResult.getBoolean("serialised"); - if (zipped && serialised) throw new IllegalArgumentException("The zipped and serialised options are incompatible"); + if (zipped && decompressor != null) throw new IllegalArgumentException("The zipped and decompressor options are incompatible"); + if ((zipped || decompressor != null) && serialised) throw new IllegalArgumentException("The zipped/decompressor and serialised options are incompatible"); + + if (zipped) decompressor = GZIPInputStream.class; if (serialised) termList = (List<? extends CharSequence>) (termFile != null ? BinIO.loadObject(termFile) : BinIO.loadObject(System.in)); + else if (termFile != null) termList = new FileLinesMutableStringIterable(termFile, encoding, decompressor); else { - if (termFile != null) termList = new FileLinesCollection(termFile, encoding.name(), zipped); - else { - final ObjectArrayList<MutableString> list = new ObjectArrayList<>(); - termList = list; - final FastBufferedReader terms = new FastBufferedReader(new InputStreamReader( - zipped ? new GZIPInputStream(System.in) : System.in, encoding.name())); - final MutableString term = new MutableString(); - while(terms.readLine(term) != null) list.add(term.copy()); - terms.close(); - } + final ObjectArrayList<String> list = new ObjectArrayList<>(); + termList = list; + FileLinesMutableStringIterable.iterator(System.in, encoding, decompressor).forEachRemaining(s -> list.add(s.toString())); } BinIO.storeObject(new ImmutableExternalPrefixMap(termList, jsapResult.getInt("blockSize"), jsapResult.getString("dump")), jsapResult.getString("map")); diff --git a/src/it/unimi/dsi/big/util/LiterallySignedStringMap.java b/src/it/unimi/dsi/big/util/LiterallySignedStringMap.java index d3c39e260b5e2e28fb7ff1f792bf19934ed6d175..93405690dab088a74b31e5a4a3ea9aa01e6b307f 100644 --- a/src/it/unimi/dsi/big/util/LiterallySignedStringMap.java +++ b/src/it/unimi/dsi/big/util/LiterallySignedStringMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2009-2020 Sebastiano Vigna + * Copyright (C) 2009-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; @@ -23,6 +22,7 @@ package it.unimi.dsi.big.util; import java.io.IOException; import java.io.Serializable; import java.nio.charset.Charset; +import java.util.zip.GZIPInputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,12 +37,13 @@ import com.martiansoftware.jsap.Switch; import com.martiansoftware.jsap.UnflaggedOption; import com.martiansoftware.jsap.stringparsers.ForNameStringParser; -import it.unimi.dsi.big.io.FileLinesCollection; import it.unimi.dsi.fastutil.Size64; import it.unimi.dsi.fastutil.io.BinIO; import it.unimi.dsi.fastutil.objects.AbstractObject2LongFunction; import it.unimi.dsi.fastutil.objects.Object2LongFunction; +import it.unimi.dsi.fastutil.objects.ObjectBigArrayBigList; import it.unimi.dsi.fastutil.objects.ObjectBigList; +import it.unimi.dsi.io.FileLinesMutableStringIterable; import it.unimi.dsi.lang.MutableString; /** A string map based on a function signed using the original list of strings. @@ -159,7 +160,11 @@ public class LiterallySignedStringMap extends AbstractObject2LongFunction<CharSe final boolean zipped = jsapResult.getBoolean("zipped"); final boolean text = jsapResult.getBoolean("text"); - final ObjectBigList<MutableString> list = text ? new FileLinesCollection(listName, encoding.toString(), zipped).allLines() : (ObjectBigList)BinIO.loadObject(listName); + final ObjectBigList<MutableString> list; + if (text) { + list = new ObjectBigArrayBigList<>(); + for (final MutableString s : new FileLinesMutableStringIterable(listName, encoding.toString(), zipped ? GZIPInputStream.class : null)) list.add(s.copy()); + } else list = (ObjectBigList<MutableString>)BinIO.loadObject(listName); final Logger logger = LoggerFactory.getLogger(LiterallySignedStringMap.class); logger.info("Signing..."); diff --git a/src/it/unimi/dsi/big/util/LongBigListSignedStringMap.java b/src/it/unimi/dsi/big/util/LongBigListSignedStringMap.java index 09d423ad15527445d8f9ab51ec4800c5d65d913a..1bc95f59bce5ae78c20a3c996924f0921b849462 100644 --- a/src/it/unimi/dsi/big/util/LongBigListSignedStringMap.java +++ b/src/it/unimi/dsi/big/util/LongBigListSignedStringMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/PermutedFrontCodedStringBigList.java b/src/it/unimi/dsi/big/util/PermutedFrontCodedStringBigList.java index 26eba8a3d0830f4d750fb3fefe5c70c66db33ae2..640aa64cdb800124c6b835fb05bdca1779babb33 100644 --- a/src/it/unimi/dsi/big/util/PermutedFrontCodedStringBigList.java +++ b/src/it/unimi/dsi/big/util/PermutedFrontCodedStringBigList.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/PrefixMap.java b/src/it/unimi/dsi/big/util/PrefixMap.java index 22e533fbc5ffd399c68cda69419956cc5a716fb9..79157d37c73072d21c9b428157182e4fe7283aa4 100644 --- a/src/it/unimi/dsi/big/util/PrefixMap.java +++ b/src/it/unimi/dsi/big/util/PrefixMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2004-2020 Sebastiano Vigna + * Copyright (C) 2004-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/SemiExternalGammaBigList.java b/src/it/unimi/dsi/big/util/SemiExternalGammaBigList.java index b2354c8f4c353a527c0ae7e0f4c5ebc0a8f50e3c..26756509c0f505b4dc014f2ab36f92a1a4c91910 100644 --- a/src/it/unimi/dsi/big/util/SemiExternalGammaBigList.java +++ b/src/it/unimi/dsi/big/util/SemiExternalGammaBigList.java @@ -1,22 +1,21 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - * - */ + * Copyright (C) 2007-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/ShiftAddXorSignedStringMap.java b/src/it/unimi/dsi/big/util/ShiftAddXorSignedStringMap.java index dc07db8b6456e5a9b9cb0b9c54b04822e23bbd8b..4854b89f4287a3af6a6ca21f9e530fef79140c7c 100644 --- a/src/it/unimi/dsi/big/util/ShiftAddXorSignedStringMap.java +++ b/src/it/unimi/dsi/big/util/ShiftAddXorSignedStringMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2008-2020 Sebastiano Vigna + * Copyright (C) 2008-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/StringMap.java b/src/it/unimi/dsi/big/util/StringMap.java index 27195a6f08825467bef41e3e5432fafe5dc01ad2..e376d8062a75cd803b1808e8946a4d50f7f112ef 100644 --- a/src/it/unimi/dsi/big/util/StringMap.java +++ b/src/it/unimi/dsi/big/util/StringMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2008-2020 Sebastiano Vigna + * Copyright (C) 2008-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/StringMaps.java b/src/it/unimi/dsi/big/util/StringMaps.java index bc141fd9cd9ef75e86fa28ada35f079fd31f2726..843b26655079a909d7d0b960c38bbf9e0d653756 100644 --- a/src/it/unimi/dsi/big/util/StringMaps.java +++ b/src/it/unimi/dsi/big/util/StringMaps.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2008-2020 Sebastiano Vigna + * Copyright (C) 2008-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/TernaryIntervalSearchTree.java b/src/it/unimi/dsi/big/util/TernaryIntervalSearchTree.java index 8dbfd42f27edf709a5cf3f2d7129bc48025e106f..c08b320ff63c4f69c4611ef88e8434a8d2a293df 100644 --- a/src/it/unimi/dsi/big/util/TernaryIntervalSearchTree.java +++ b/src/it/unimi/dsi/big/util/TernaryIntervalSearchTree.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/package-info.java b/src/it/unimi/dsi/big/util/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..a6b440e30ba67520f289e16f452d8cf98a2335b7 --- /dev/null +++ b/src/it/unimi/dsi/big/util/package-info.java @@ -0,0 +1,6 @@ +/** Collections and similar big classes + * + * <p>Classes in this package are big versions of classes in {@link it.unimi.dsi.util}. + */ + +package it.unimi.dsi.big.util; diff --git a/src/it/unimi/dsi/big/util/package.html b/src/it/unimi/dsi/big/util/package.html deleted file mode 100644 index 680dba9c1fcd9de4cb42484709d85336817a3d75..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/big/util/package.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>Collections and similar big classes</title> - </head> - - <body> - - <P>Collections and similar big classes. - - <h2>Package Specification</h2> - - <p>Classes in this package are big versions of classes in {@link it.unimi.dsi.util}. - </body> -</html> diff --git a/src/it/unimi/dsi/bits/AbstractBitVector.java b/src/it/unimi/dsi/bits/AbstractBitVector.java index acbae54bd685ab84f97a80bd134dfe2216449a18..ec431609323276a4c6a8944db384a9701377d7b0 100644 --- a/src/it/unimi/dsi/bits/AbstractBitVector.java +++ b/src/it/unimi/dsi/bits/AbstractBitVector.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/src/it/unimi/dsi/bits/BitVector.java b/src/it/unimi/dsi/bits/BitVector.java index e21a69e9547bf1cb607a162f1041df222bb05789..b8c0a04767af915e4fe139f394de9463b7790d21 100644 --- a/src/it/unimi/dsi/bits/BitVector.java +++ b/src/it/unimi/dsi/bits/BitVector.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; @@ -28,87 +27,107 @@ import it.unimi.dsi.fastutil.booleans.BooleanList; import it.unimi.dsi.fastutil.longs.LongBigList; import it.unimi.dsi.fastutil.longs.LongSortedSet; -/** A vector of bits, a.k.a. bit sequence, bit string, binary word, etc. +/** + * A vector of bits, a.k.a. bit sequence, bit string, binary word, etc. * - * <P>This interface define several operations on finite sequences of bits. - * Efficient implementations, such as {@link LongArrayBitVector}, - * use approximately one bit of memory for each bit in the vector, but this is not enforced. + * <P> + * This interface define several operations on finite sequences of bits. Efficient implementations, + * such as {@link LongArrayBitVector}, use approximately one bit of memory for each bit in the + * vector, but this is not enforced. * - * <P>Operation of a bit vector are partially of boolean nature - * (e.g., logical operations between vectors), - * partially of language-theoretical nature (e.g., concatenation), and - * partially of set-theoretical nature (e.g., asking which bits are set to one). - * To accomodate all these points of view, this interface extends - * {@link it.unimi.dsi.fastutil.booleans.BooleanBigList}, but also provides an - * {@link #asLongSet()} method that exposes a {@link java.util.BitSet}-like view - * and a {@link #asLongBigList(int)} method that provides integer-like access to - * blocks of bits of given width. + * <P> + * Operation of a bit vector are partially of boolean nature (e.g., logical operations between + * vectors), partially of language-theoretical nature (e.g., concatenation), and partially of + * set-theoretical nature (e.g., asking which bits are set to one). To accomodate all these points + * of view, this interface extends {@link it.unimi.dsi.fastutil.booleans.BooleanBigList}, but also + * provides an {@link #asLongSet()} method that exposes a {@link java.util.BitSet}-like view and a + * {@link #asLongBigList(int)} method that provides integer-like access to blocks of bits of given + * width. * - * <P>Most, if not all, classical operations on bit vectors can be seen as standard - * operations on these two views: for instance, the number of bits set to one is just - * the number of elements of the set returned by {@link #asLongSet()} (albeit a direct {@link #count()} method - * is provided, too). The standard {@link java.util.Collection#addAll(java.util.Collection)} method - * can be used to concatenate bit vectors, and {@linkplain it.unimi.dsi.fastutil.booleans.BooleanBigList#subList(long, long) sublist views} - * make it easy performing any kind of logical operation on subvectors. + * <P> + * Most, if not all, classical operations on bit vectors can be seen as standard operations on these + * two views: for instance, the number of bits set to one is just the number of elements of the set + * returned by {@link #asLongSet()} (albeit a direct {@link #count()} method is provided, too). The + * standard {@link java.util.Collection#addAll(java.util.Collection)} method can be used to + * concatenate bit vectors, and + * {@linkplain it.unimi.dsi.fastutil.booleans.BooleanBigList#subList(long, long) sublist views} make + * it easy performing any kind of logical operation on subvectors. * - * <P>The only <i>caveat</i> is that sometimes the standard interface naming clashes slightly - * with standard usage: for instance, {@link #clear()} will <em>not</em> set to zero - * all bits (use {@link #fill(int) fill(0)} for that purpose), but rather will set the - * vector length to zero. Also, {@link #add(long, int)} will not add logically a value at - * the specified index, but rather will insert a new bit with the specified value at the specified - * position. + * <P> + * The only <i>caveat</i> is that sometimes the standard interface naming clashes slightly with + * standard usage: for instance, {@link #clear()} will <em>not</em> set to zero all bits (use + * {@link #fill(int) fill(0)} for that purpose), but rather will set the vector length to zero. + * Also, {@link #add(long, int)} will not add logically a value at the specified index, but rather + * will insert a new bit with the specified value at the specified position. * - * <P>To increase clarity, this interface provides methods {@link #length()} and {@link #length(long)} + * <P> + * To increase clarity, this interface provides methods {@link #length()} and {@link #length(long)} * which have a semantics similar to {@link #size64()} and {@link #size(long)}. * - * <P>The {@link AbstractBitVector} class provides a fairly complete - * abstract implementation that provides all methods except for the most - * basic operations. Of course, the methods of {@link AbstractBitVector} are - * sometimes very inefficient, but implementations such as {@link LongArrayBitVector} - * have their own optimised implementations. + * <P> + * The {@link AbstractBitVector} class provides a fairly complete abstract implementation that + * provides all methods except for the most basic operations. Of course, the methods of + * {@link AbstractBitVector} are sometimes very inefficient, but implementations such as + * {@link LongArrayBitVector} have their own optimised implementations. */ public interface BitVector extends RandomAccess, BooleanBigList { - /** Sets a bit in this bit vector (optional operation). + /** + * Sets a bit in this bit vector (optional operation). + * * @param index the index of a bit. */ void set(long index); - /** Clears a bit in this bit vector (optional operation). + /** + * Clears a bit in this bit vector (optional operation). + * * @param index the index of a bit. */ void clear(long index); - /** Flips a bit in this bit vector (optional operation). + /** + * Flips a bit in this bit vector (optional operation). + * * @param index the index of a bit. */ void flip(long index); - /** Fills a range of bits in this bit vector (optional operation). + /** + * Fills a range of bits in this bit vector (optional operation). + * * @param from the first index (inclusive). * @param to the last index (not inclusive). * @param value the value (true or false). */ void fill(long from, long to, boolean value); - /** Clears a range of bits in this bit vector (optional operation). + /** + * Clears a range of bits in this bit vector (optional operation). + * * @param from the first index (inclusive). * @param to the last index (not inclusive). * @param value the value (zero or nonzero). */ void fill(long from, long to, int value); - /** Sets all bits this bit vector to the given boolean value (optional operation). + /** + * Sets all bits this bit vector to the given boolean value (optional operation). + * * @param value the value (true or false). */ void fill(boolean value); - /** Sets all bits this bit vector to the given integer value (optional operation). + /** + * Sets all bits this bit vector to the given integer value (optional operation). + * * @param value the value (zero or nonzero). */ void fill(int value); - /** Flips a range of bits in this bit vector (optional operation). + /** + * Flips a range of bits in this bit vector (optional operation). + * * @param from the first index (inclusive). * @param to the last index (not inclusive). */ @@ -117,71 +136,84 @@ public interface BitVector extends RandomAccess, BooleanBigList { /** Flips all bits in this bit vector (optional operation). */ void flip(); - /** Replaces the content of this bit vector with another bit vector. + /** + * Replaces the content of this bit vector with another bit vector. * * @param bitVector a bit vector. * @return this bit vector. */ BitVector replace(BitVector bitVector); - /** Returns a subvector view specified by initial and final index. + /** + * Returns a subvector view specified by initial and final index. * - * <p>The object returned by this method is a bit vector representing a <em>view</em> of this - * bit vector restricted to the given indices. Changes to the subvector - * will be reflected in the main vector. + * <p> + * The object returned by this method is a bit vector representing a <em>view</em> of this bit + * vector restricted to the given indices. Changes to the subvector will be reflected in the main + * vector. * * @param from the first index (inclusive). * @param to the last index (not inclusive). */ BitVector subVector(long from, long to); - /** Returns a subvector view specified by initial index and running up to the end of this vector. + /** + * Returns a subvector view specified by initial index and running up to the end of this vector. * * @param from the first index (inclusive). * @see #subVector(long, long) */ BitVector subVector(long from); - /** Returns a view of this bit vector as a sorted set of long integers. + /** + * Returns a view of this bit vector as a sorted set of long integers. * - * <P>More formally, this bit vector is infinitely extended to the - * left with zeros (e.g., all bits beyond {@link #length(long)} are - * considered zeroes). The resulting infinite string is interpreted as the - * characteristic function of a set of integers. + * <P> + * More formally, this bit vector is infinitely extended to the left with zeros (e.g., all bits + * beyond {@link #length(long)} are considered zeroes). The resulting infinite string is interpreted + * as the characteristic function of a set of integers. * - * <P>Note that, in particular, the resulting string representation is - * exactly that of a {@link java.util.BitSet}. + * <P> + * Note that, in particular, the resulting string representation is exactly that of a + * {@link java.util.BitSet}. * */ LongSortedSet asLongSet(); - /** Returns a view of this bit vector as a list of nonnegative integers of specified width. + /** + * Returns a view of this bit vector as a list of nonnegative integers of specified width. + * + * <P> + * More formally, {@link LongBigList#getLong(long) getLong(p)} will return the nonnegative integer + * defined by the bits starting at <code>p * width</code> (bit 0, inclusive) and ending at + * <code>(p + 1) * width</code> (bit <code>width</code> − 1, exclusive). * - * <P>More formally, {@link LongBigList#getLong(long) getLong(p)} will return - * the nonnegative integer defined by the bits starting at <code>p * width</code> (bit 0, inclusive) - * and ending at <code>(p + 1) * width</code> (bit <code>width</code> − 1, exclusive). + * @param width a bit width. */ LongBigList asLongBigList(int width); - /** Returns the value of the specified bit as an integer. + /** + * Returns the value of the specified bit as an integer. * - * <P>This method is a useful synonym for {@link #getBoolean(long)}. + * <P> + * This method is a useful synonym for {@link #getBoolean(long)}. * * @param index the index of a bit. * @return the value of the specified bit as an integer (0 or 1). */ int getInt(long index); - /** Returns the specified bit range as a long. + /** + * Returns the specified bit range as a long. * - * <P>Note that bit 0 of the returned long will be bit <code>from</code> - * of this bit vector. + * <P> + * Note that bit 0 of the returned long will be bit <code>from</code> of this bit vector. * - * <P>Implementations are invited to provide high-speed implementations for - * the case in which <code>from</code> is a multiple of {@link Long#SIZE} - * and <code>to</code> is <code>from</code> + {@link Long#SIZE} (or less, - * in case the vector length is exceeded). This behaviour make it possible to - * implement high-speed hashing, copies, etc. + * <P> + * Implementations are invited to provide high-speed implementations for the case in which + * <code>from</code> is a multiple of {@link Long#SIZE} and <code>to</code> is <code>from</code> + + * {@link Long#SIZE} (or less, in case the vector length is exceeded). This behaviour make it + * possible to implement high-speed hashing, copies, etc. * * @param from the starting bit (inclusive). * @param to the ending bit (exclusive). @@ -189,34 +221,42 @@ public interface BitVector extends RandomAccess, BooleanBigList { */ long getLong(long from, long to); - /** Sets the value of the specified bit as an integer (optional operation). + /** + * Sets the value of the specified bit as an integer (optional operation). * - * <P>This method is a useful synonym for {@link #set(long, boolean)}. + * <P> + * This method is a useful synonym for {@link #set(long, boolean)}. * * @param index the index of a bit. * @param value the new value (any nonzero integer for setting the bit, zero for clearing the bit). */ void set(long index, int value); - /** Adds a bit with specified integer value at the specified index (optional operation). + /** + * Adds a bit with specified integer value at the specified index (optional operation). * - * <P>This method is a useful synonym for {@link #add(long, boolean)}. + * <P> + * This method is a useful synonym for {@link #add(long, boolean)}. * * @param index the index of a bit. - * @param value the value that will be inserted at position <code>index</code> (any nonzero integer for a true bit, zero for a false bit). + * @param value the value that will be inserted at position <code>index</code> (any nonzero integer + * for a true bit, zero for a false bit). */ void add(long index, int value); - /** Adds a bit with specified value at the end of this bit vector. + /** + * Adds a bit with specified value at the end of this bit vector. * - * <P>This method is a useful synonym for {@link BooleanList#add(boolean)}. + * <P> + * This method is a useful synonym for {@link BooleanList#add(boolean)}. * * @param value the new value (any nonzero integer for a true bit, zero for a false bit). */ void add(int value); - /** Appends the less significant bits of a long integer to this bit vector. + /** + * Appends the less significant bits of a long integer to this bit vector. * * @param value a value to be appended * @param k the number of less significant bits to be added to this bit vector. @@ -225,7 +265,8 @@ public interface BitVector extends RandomAccess, BooleanBigList { BitVector append(long value, int k); - /** Appends another bit vector to this bit vector. + /** + * Appends another bit vector to this bit vector. * * @param bitVector a bit vector to be appended. * @return this bit vector. @@ -233,156 +274,189 @@ public interface BitVector extends RandomAccess, BooleanBigList { BitVector append(BitVector bitVector); - /** Returns the number of bits in this bit vector. + /** + * Returns the number of bits in this bit vector. * - * <p>If the number of bits in this vector is smaller than or equal to {@link Integer#MAX_VALUE}, this - * method is semantically equivalent to {@link List#size()}. In any case, this method is semantically - * equivalent to {@link BooleanBigList#size64()}, but it is prefererred. + * <p> + * If the number of bits in this vector is smaller than or equal to {@link Integer#MAX_VALUE}, this + * method is semantically equivalent to {@link List#size()}. In any case, this method is + * semantically equivalent to {@link BooleanBigList#size64()}, but it is prefererred. * * @return the number of bits in this bit vector. */ long length(); - /** Sets the number of bits in this bit vector. + /** + * Sets the number of bits in this bit vector. * - * <p>It is expected that this method will try to allocate exactly - * the necessary space. + * <p> + * It is expected that this method will try to allocate exactly the necessary space. * - * <p>If the argument fits an integer, this - * method has the same side effects of {@link BooleanList#size(int)}. - * In any case, this method has the same side effects of - * {@link BooleanBigList#size(long)}, but it is preferred, - * as it has the advantage of returning this bit vector, - * thus making it possible to chain methods. + * <p> + * If the argument fits an integer, this method has the same side effects of + * {@link BooleanList#size(int)}. In any case, this method has the same side effects of + * {@link BooleanBigList#size(long)}, but it is preferred, as it has the advantage of returning this + * bit vector, thus making it possible to chain methods. * + * @param newLength the new length in bits for this bit vector. * @return this bit vector. */ BitVector length(long newLength); - /** Counts the number of bits set to true in this bit vector. + /** + * Counts the number of bits set to true in this bit vector. * * @return the number of bits set to true in this bit vector. */ long count(); - /** Performs a logical and between this bit vector and another one, leaving the result in this vector. + /** + * Performs a logical and between this bit vector and another one, leaving the result in this + * vector. * * @param v a bit vector. * @return this bit vector. */ BitVector and(BitVector v); - /** Performs a logical or between this bit vector and another one, leaving the result in this vector. + /** + * Performs a logical or between this bit vector and another one, leaving the result in this vector. * * @param v a bit vector. * @return this bit vector. */ BitVector or(BitVector v); - /** Performs a logical xor between this bit vector and another one, leaving the result in this vector. + /** + * Performs a logical xor between this bit vector and another one, leaving the result in this + * vector. * * @param v a bit vector. * @return this bit vector. */ BitVector xor(BitVector v); - /** Returns the position of the first bit set in this vector. + /** + * Returns the position of the first bit set in this vector. * * @return the first bit set, or -1 for a vector of zeroes. */ long firstOne(); - /** Returns the position of the last bit set in this vector. + /** + * Returns the position of the last bit set in this vector. * * @return the last bit set, or -1 for a vector of zeroes. */ long lastOne(); - /** Returns the position of the first bit set at of after the given position. + /** + * Returns the position of the first bit set at of after the given position. * - * @return the position of the first bit set at or after position <code>index</code>, or -1 if no such bit exists. + * @param index a bit position. + * @return the position of the first bit set at or after position <code>index</code>, or -1 if no + * such bit exists. */ long nextOne(long index); - /** Returns the position of the first bit set strictly before the given position. + /** + * Returns the position of the first bit set strictly before the given position. * - * @return the position of the first bit set strictly before position <code>index</code>, or -1 if no such bit exists. + * @param index a bit position. + * @return the position of the first bit set strictly before position <code>index</code>, or -1 if + * no such bit exists. */ long previousOne(long index); - /** Returns the position of the first bit unset in this vector. + /** + * Returns the position of the first bit unset in this vector. * * @return the first bit unset, or -1 for a vector of ones. */ long firstZero(); - /** Returns the position of the last bit unset in this vector. + /** + * Returns the position of the last bit unset in this vector. * * @return the last bit unset, or -1 for a vector of ones. */ long lastZero(); - /** Returns the position of the first bit unset after the given position. + /** + * Returns the position of the first bit unset after the given position. * - * @return the first bit unset after position <code>index</code> (inclusive), or -1 if no such bit exists. + * @param index a bit position. + * @return the first bit unset after position <code>index</code> (inclusive), or -1 if no such bit + * exists. */ long nextZero(long index); - /** Returns the position of the first bit unset before or at the given position. + /** + * Returns the position of the first bit unset before or at the given position. * + * @param index a bit position. * @return the first bit unset before or at the given position, or -1 if no such bit exists. */ long previousZero(long index); - /** Returns the length of the greatest common prefix between this and the specified vector. + /** + * Returns the length of the greatest common prefix between this and the specified vector. * * @param v a bit vector. * @return the length of the greatest common prefix. */ long longestCommonPrefixLength(BitVector v); - /** Returns true if this vector is a prefix of the specified vector. + /** + * Returns true if this vector is a prefix of the specified vector. * * @param v a bit vector. * @return true if this vector is a prefix of <code>v</code>. */ boolean isPrefix(BitVector v); - /** Returns true if this vector is a proper prefix of the specified vector. + /** + * Returns true if this vector is a proper prefix of the specified vector. * * @param v a bit vector. - * @return true if this vector is a proper prefix of <code>v</code> (i.e., it is a prefix but not equal). + * @return true if this vector is a proper prefix of <code>v</code> (i.e., it is a prefix but not + * equal). */ boolean isProperPrefix(BitVector v); - /** Checks for equality with a segment of another vector. + /** + * Checks for equality with a segment of another vector. * * @param v a bit vector. * @param from the starting bit, inclusive. * @param to the ending bit, not inclusive. - * @return true if this vector and v are equal in the range of positions [<code>from</code>..<code>to</code>). + * @return true if this vector and v are equal in the range of positions + * [<code>from</code>..<code>to</code>). */ boolean equals(final BitVector v, final long from, final long to); - /** Returns a copy of a part of this bit vector. + /** + * Returns a copy of a part of this bit vector. * * @param from the starting bit, inclusive. * @param to the ending bit, not inclusive. - * @return a copy of the part of this bit vector going from bit <code>from</code> (inclusive) to bit <code>to</code> - * (not inclusive) + * @return a copy of the part of this bit vector going from bit <code>from</code> (inclusive) to bit + * <code>to</code> (not inclusive) */ BitVector copy(long from, long to); - /** Returns a copy of this bit vector. + /** + * Returns a copy of this bit vector. * * @return a copy of this bit vector. */ BitVector copy(); - /** Returns the bits in this bit vector as an array of longs, not to be modified. + /** + * Returns the bits in this bit vector as an array of longs, not to be modified. * - * @return an array of longs whose first {@link #length()} bits contain the bits of - * this bit vector. The array cannot be modified. + * @return an array of longs whose first {@link #length()} bits contain the bits of this bit vector. + * The array cannot be modified. */ long[] bits(); @@ -422,26 +496,31 @@ public interface BitVector extends RandomAccess, BooleanBigList { @Override int hashCode(); - /** Returns a fast version of this bit vector. + /** + * Returns a fast version of this bit vector. * - * <p>Different implementations of this interface might provide different level of efficiency. - * For instance, <em>views</em> on other data structures (e.g., strings) might implement - * {@link #getLong(long, long)} efficiently on multiples of {@link Long#SIZE}, but might - * fail to provide a generic, truly efficient random access. + * <p> + * Different implementations of this interface might provide different level of efficiency. For + * instance, <em>views</em> on other data structures (e.g., strings) might implement + * {@link #getLong(long, long)} efficiently on multiples of {@link Long#SIZE}, but might fail to + * provide a generic, truly efficient random access. * - * <p>This method returns a (possibly immutable) bit vector with the same content as - * that of this bit vector. However, the returned bit vector is guaranteed to provide fast random access. + * <p> + * This method returns a (possibly immutable) bit vector with the same content as that of this bit + * vector. However, the returned bit vector is guaranteed to provide fast random access. * * @return a fast version of this bit vector. */ BitVector fast(); - - /** {@inheritDoc} - * @deprecated Please use {@link #size64()} instead. */ + /** + * {@inheritDoc} + * + * @deprecated Please use {@link #size64()} instead. + */ @Deprecated @Override default int size() { - return (int) Math.min(Integer.MAX_VALUE, size64()); + return (int)Math.min(Integer.MAX_VALUE, size64()); } } diff --git a/src/it/unimi/dsi/bits/BitVectors.java b/src/it/unimi/dsi/bits/BitVectors.java index af2d39cf30bf2a08e02be8247a03fb8696c925f4..2851126e9e77869e73bd402d10d29f2b9172922a 100644 --- a/src/it/unimi/dsi/bits/BitVectors.java +++ b/src/it/unimi/dsi/bits/BitVectors.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/src/it/unimi/dsi/bits/BooleanListBitVector.java b/src/it/unimi/dsi/bits/BooleanListBitVector.java index faee1c4678437030a686f72cb710d68d77ff13e0..38f4dff7dfd078d0e8683d703852ff2a1befc1eb 100644 --- a/src/it/unimi/dsi/bits/BooleanListBitVector.java +++ b/src/it/unimi/dsi/bits/BooleanListBitVector.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/src/it/unimi/dsi/bits/Fast.java b/src/it/unimi/dsi/bits/Fast.java index b7efa7d2bedbdfcb134af2cfecf0d66582e21a66..d93032b704992535e5217f1907cb1b6e35545097 100644 --- a/src/it/unimi/dsi/bits/Fast.java +++ b/src/it/unimi/dsi/bits/Fast.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/src/it/unimi/dsi/bits/HuTuckerTransformationStrategy.java b/src/it/unimi/dsi/bits/HuTuckerTransformationStrategy.java index e8afc92d0f09842135b0bfb7c1a1e39134681f7e..e0b7cd1838d0b77418b89341461e0a51d0f3f6d7 100644 --- a/src/it/unimi/dsi/bits/HuTuckerTransformationStrategy.java +++ b/src/it/unimi/dsi/bits/HuTuckerTransformationStrategy.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/src/it/unimi/dsi/bits/LongArrayBitVector.java b/src/it/unimi/dsi/bits/LongArrayBitVector.java index 5f9fb4e89cef5901a739423472f6b0178619cc2d..613d239b7e79bf4f63fbb8f38474e7a7a227bbec 100644 --- a/src/it/unimi/dsi/bits/LongArrayBitVector.java +++ b/src/it/unimi/dsi/bits/LongArrayBitVector.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/src/it/unimi/dsi/bits/LongBigArrayBitVector.java b/src/it/unimi/dsi/bits/LongBigArrayBitVector.java index 52a169af6ef32ec5f44d724e15839a478794f3e9..5934d56596d4f4a58929b458b8e241a582642f0c 100644 --- a/src/it/unimi/dsi/bits/LongBigArrayBitVector.java +++ b/src/it/unimi/dsi/bits/LongBigArrayBitVector.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/src/it/unimi/dsi/bits/PrefixCoderTransformationStrategy.java b/src/it/unimi/dsi/bits/PrefixCoderTransformationStrategy.java index 0c4bc742cc1bef3d569668a8f4b3260b42ab1489..f40202f19992aa31e3b03856d0d9056c1200f593 100644 --- a/src/it/unimi/dsi/bits/PrefixCoderTransformationStrategy.java +++ b/src/it/unimi/dsi/bits/PrefixCoderTransformationStrategy.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/src/it/unimi/dsi/bits/TransformationStrategies.java b/src/it/unimi/dsi/bits/TransformationStrategies.java index 7059fef58ef3018a48d5213538bd96debf54f15c..a76a00e8452c0b7e9a4557a1e9ed32a798702bba 100644 --- a/src/it/unimi/dsi/bits/TransformationStrategies.java +++ b/src/it/unimi/dsi/bits/TransformationStrategies.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; @@ -274,6 +273,7 @@ public class TransformationStrategies { public long getLong(final long from, final long to) { final int startBit = (int)(from & CHAR_MASK); if (startBit == 0) { + final char[] a = this.a; final int pos = (int)(from >>> LOG2_CHAR_SIZE); if (to == from + Long.SIZE) return (long)a[pos + 3] << 48 | (long)a[pos + 2] << 32 | (long)a[pos + 1] << 16 | a[pos]; @@ -281,9 +281,12 @@ public class TransformationStrategies { if ((to & CHAR_MASK) == 0) { long word = 0; switch ((int)((to - from) >>> LOG2_CHAR_SIZE)) { - case 3: word |= (long)a[pos + 2] << 32; - case 2: word |= (long)a[pos + 1] << 16; - case 1: word |= a[pos + 0]; + case 3: + word |= (long)a[pos + 2] << 32; + case 2: + word |= (long)a[pos + 1] << 16; + case 1: + word |= a[pos + 0]; } return word; } @@ -294,7 +297,7 @@ public class TransformationStrategies { if (l == Long.SIZE) return 0; if (startBit <= l) return getLong(startPos, Math.min(length, startPos + Long.SIZE)) << l - startBit >>> l; - return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << Long.SIZE + l - startBit >>> l; + return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << l - startBit >>> l; } @Override @@ -326,6 +329,7 @@ public class TransformationStrategies { public long getLong(final long from, final long to) { final int startBit = (int)(from & CHAR_MASK); if (startBit == 0) { + final CharSequence s = this.s; final int pos = (int)(from >>> LOG2_CHAR_SIZE); if (to == from + Long.SIZE) return (long)s.charAt(pos + 3) << 48 | (long)s.charAt(pos + 2) << 32 | (long)s.charAt(pos + 1) << 16 | s.charAt(pos); @@ -333,9 +337,12 @@ public class TransformationStrategies { if ((to & CHAR_MASK) == 0) { long word = 0; switch ((int)((to - from) >>> LOG2_CHAR_SIZE)) { - case 3: word |= (long)s.charAt(pos + 2) << 32; - case 2: word |= (long)s.charAt(pos + 1) << 16; - case 1: word |= s.charAt(pos + 0); + case 3: + word |= (long)s.charAt(pos + 2) << 32; + case 2: + word |= (long)s.charAt(pos + 1) << 16; + case 1: + word |= s.charAt(pos + 0); } return word; } @@ -346,7 +353,7 @@ public class TransformationStrategies { if (l == Long.SIZE) return 0; if (startBit <= l) return getLong(startPos, Math.min(length, startPos + Long.SIZE)) << l - startBit >>> l; - return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << Long.SIZE + l - startBit >>> l; + return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << l - startBit >>> l; } @Override @@ -444,6 +451,7 @@ public class TransformationStrategies { public long getLong(final long from, final long to) { final int startBit = (int)(from & CHAR_MASK); if (startBit == 0) { + final CharSequence s = this.s; final int pos = (int)(from >>> LOG2_CHAR_SIZE); if (to == from + Long.SIZE) return reverseChars((to > actualEnd ? 0 : (long)s.charAt(pos + 3)) << 48 | (long)s.charAt(pos + 2) << 32 | (long)s.charAt(pos + 1) << 16 | s.charAt(pos)); @@ -451,9 +459,12 @@ public class TransformationStrategies { if ((to & CHAR_MASK) == 0) { long word = 0; switch ((int)((Math.min(to, actualEnd) - Math.min(from, actualEnd)) >>> LOG2_CHAR_SIZE)) { - case 3: word |= (long)s.charAt(pos + 2) << 32; - case 2: word |= (long)s.charAt(pos + 1) << 16; - case 1: word |= s.charAt(pos); + case 3: + word |= (long)s.charAt(pos + 2) << 32; + case 2: + word |= (long)s.charAt(pos + 1) << 16; + case 1: + word |= s.charAt(pos); } return reverseChars(word); } @@ -464,7 +475,7 @@ public class TransformationStrategies { if (l == Long.SIZE) return 0; if (startBit <= l) return getLong(startPos, Math.min(length, startPos + Long.SIZE)) << l - startBit >>> l; - return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << Long.SIZE + l - startBit >>> l; + return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << l - startBit >>> l; } @Override @@ -499,15 +510,19 @@ public class TransformationStrategies { public long getLong(final long from, final long to) { final int startBit = (int)(from & CHAR_MASK); if (startBit == 0) { + final char[] a = this.a; final int pos = (int)(from >>> LOG2_CHAR_SIZE); if (to == from + Long.SIZE) return reverseChars((to > actualEnd ? 0 : (long)a[pos + 3]) << 48 | (long)a[pos + 2] << 32 | (long)a[pos + 1] << 16 | a[pos]); if ((to & CHAR_MASK) == 0) { long word = 0; switch ((int)((Math.min(to, actualEnd) - Math.min(from, actualEnd)) >>> LOG2_CHAR_SIZE)) { - case 3: word |= (long)a[pos + 2] << 32; - case 2: word |= (long)a[pos + 1] << 16; - case 1: word |= a[pos]; + case 3: + word |= (long)a[pos + 2] << 32; + case 2: + word |= (long)a[pos + 1] << 16; + case 1: + word |= a[pos]; } return reverseChars(word); } @@ -518,7 +533,7 @@ public class TransformationStrategies { if (l == Long.SIZE) return 0; if (startBit <= l) return getLong(startPos, Math.min(length, startPos + Long.SIZE)) << l - startBit >>> l; - return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << Long.SIZE + l - startBit >>> l; + return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << l - startBit >>> l; } @Override @@ -594,6 +609,7 @@ public class TransformationStrategies { public long getLong(final long from, final long to) { final int startBit = (int)(from & BYTE_MASK); if (startBit == 0) { + final CharSequence s = this.s; final int pos = (int)(from >>> LOG2_BYTE_SIZE); if (to == from + Long.SIZE) return (s.charAt(pos + 7) & 0xFFL) << 56 | @@ -601,20 +617,25 @@ public class TransformationStrategies { (s.charAt(pos + 5) & 0xFFL) << 40 | (s.charAt(pos + 4) & 0xFFL) << 32 | (s.charAt(pos + 3) & 0xFFL) << 24 | - (s.charAt(pos + 2) & 0xFF) << 16 | - (s.charAt(pos + 1) & 0xFF) << 8 | - (s.charAt(pos) & 0xFF); + (s.charAt(pos + 2) & 0xFFL) << 16 | (s.charAt(pos + 1) & 0xFFL) << 8 | (s.charAt(pos) & 0xFFL); if ((to & BYTE_MASK) == 0) { long word = 0; switch ((int)((to - from) >>> LOG2_BYTE_SIZE)) { - case 7: word |= (s.charAt(pos + 6) & 0xFFL) << 48; - case 6: word |= (s.charAt(pos + 5) & 0xFFL) << 40; - case 5: word |= (s.charAt(pos + 4) & 0xFFL) << 32; - case 4: word |= (s.charAt(pos + 3) & 0xFFL) << 24; - case 3: word |= (s.charAt(pos + 2) & 0xFF) << 16; - case 2: word |= (s.charAt(pos + 1) & 0xFF) << 8; - case 1: word |= s.charAt(pos) & 0xFF; + case 7: + word |= (s.charAt(pos + 6) & 0xFFL) << 48; + case 6: + word |= (s.charAt(pos + 5) & 0xFFL) << 40; + case 5: + word |= (s.charAt(pos + 4) & 0xFFL) << 32; + case 4: + word |= (s.charAt(pos + 3) & 0xFFL) << 24; + case 3: + word |= (s.charAt(pos + 2) & 0xFFL) << 16; + case 2: + word |= (s.charAt(pos + 1) & 0xFFL) << 8; + case 1: + word |= s.charAt(pos) & 0xFFL; } return word; } @@ -625,7 +646,7 @@ public class TransformationStrategies { if (l == Long.SIZE) return 0; if (startBit <= l) return getLong(startPos, Math.min(length, startPos + Long.SIZE)) << l - startBit >>> l; - return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << Long.SIZE + l - startBit >>> l; + return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << l - startBit >>> l; } @Override @@ -655,6 +676,7 @@ public class TransformationStrategies { public long getLong(final long from, final long to) { final int startBit = (int)(from & BYTE_MASK); if (startBit == 0) { + final char[] a = this.a; final int pos = (int)(from >>> LOG2_BYTE_SIZE); if (to == from + Long.SIZE) return (a[pos + 7] & 0xFFL) << 56 | @@ -662,20 +684,25 @@ public class TransformationStrategies { (a[pos + 5] & 0xFFL) << 40 | (a[pos + 4] & 0xFFL) << 32 | (a[pos + 3] & 0xFFL) << 24 | - (a[pos + 2] & 0xFF) << 16 | - (a[pos + 1] & 0xFF) << 8 | - (a[pos] & 0xFF); + (a[pos + 2] & 0xFFL) << 16 | (a[pos + 1] & 0xFFL) << 8 | (a[pos] & 0xFFL); if ((to & BYTE_MASK) == 0) { long word = 0; switch ((int)((to - from) >>> LOG2_BYTE_SIZE)) { - case 7: word |= (a[pos + 6] & 0xFFL) << 48; - case 6: word |= (a[pos + 5] & 0xFFL) << 40; - case 5: word |= (a[pos + 4] & 0xFFL) << 32; - case 4: word |= (a[pos + 3] & 0xFFL) << 24; - case 3: word |= (a[pos + 2] & 0xFF) << 16; - case 2: word |= (a[pos + 1] & 0xFF) << 8; - case 1: word |= a[pos] & 0xFF; + case 7: + word |= (a[pos + 6] & 0xFFL) << 48; + case 6: + word |= (a[pos + 5] & 0xFFL) << 40; + case 5: + word |= (a[pos + 4] & 0xFFL) << 32; + case 4: + word |= (a[pos + 3] & 0xFFL) << 24; + case 3: + word |= (a[pos + 2] & 0xFFL) << 16; + case 2: + word |= (a[pos + 1] & 0xFFL) << 8; + case 1: + word |= a[pos] & 0xFFL; } return word; } @@ -687,7 +714,7 @@ public class TransformationStrategies { if (l == Long.SIZE) return 0; if (startBit <= l) return getLong(startPos, Math.min(length, startPos + Long.SIZE)) << l - startBit >>> l; - return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << Long.SIZE + l - startBit >>> l; + return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << l - startBit >>> l; } @Override @@ -791,6 +818,7 @@ public class TransformationStrategies { public long getLong(final long from, final long to) { final int startBit = (int)(from & BYTE_MASK); if (startBit == 0) { + final CharSequence s = this.s; final int pos = (int)(from >>> LOG2_BYTE_SIZE); if (to == from + Long.SIZE) return reverseBytes((to > actualEnd ? 0 : (s.charAt(pos + 7) & 0xFFL)) << 56 | @@ -798,20 +826,25 @@ public class TransformationStrategies { (s.charAt(pos + 5) & 0xFFL) << 40 | (s.charAt(pos + 4) & 0xFFL) << 32 | (s.charAt(pos + 3) & 0xFFL) << 24 | - (s.charAt(pos + 2) & 0xFF) << 16 | - (s.charAt(pos + 1) & 0xFF) << 8 | - (s.charAt(pos) & 0xFF)); + (s.charAt(pos + 2) & 0xFFL) << 16 | (s.charAt(pos + 1) & 0xFFL) << 8 | (s.charAt(pos) & 0xFFL)); if ((to & BYTE_MASK) == 0) { long word = 0; switch ((int)((Math.min(to, actualEnd) - Math.min(from, actualEnd)) >>> LOG2_BYTE_SIZE)) { - case 7: word |= (s.charAt(pos + 6) & 0xFFL) << 48; - case 6: word |= (s.charAt(pos + 5) & 0xFFL) << 40; - case 5: word |= (s.charAt(pos + 4) & 0xFFL) << 32; - case 4: word |= (s.charAt(pos + 3) & 0xFFL) << 24; - case 3: word |= (s.charAt(pos + 2) & 0xFF) << 16; - case 2: word |= (s.charAt(pos + 1) & 0xFF) << 8; - case 1: word |= s.charAt(pos) & 0xFF; + case 7: + word |= (s.charAt(pos + 6) & 0xFFL) << 48; + case 6: + word |= (s.charAt(pos + 5) & 0xFFL) << 40; + case 5: + word |= (s.charAt(pos + 4) & 0xFFL) << 32; + case 4: + word |= (s.charAt(pos + 3) & 0xFFL) << 24; + case 3: + word |= (s.charAt(pos + 2) & 0xFFL) << 16; + case 2: + word |= (s.charAt(pos + 1) & 0xFFL) << 8; + case 1: + word |= s.charAt(pos) & 0xFFL; } return reverseBytes(word); } @@ -822,7 +855,7 @@ public class TransformationStrategies { if (l == Long.SIZE) return 0; if (startBit <= l) return getLong(startPos, Math.min(length, startPos + Long.SIZE)) << l - startBit >>> l; - return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << Long.SIZE + l - startBit >>> l; + return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << l - startBit >>> l; } @Override @@ -857,6 +890,7 @@ public class TransformationStrategies { public long getLong(final long from, final long to) { final int startBit = (int)(from & BYTE_MASK); if (startBit == 0) { + final char[] a = this.a; final int pos = (int)(from >>> LOG2_BYTE_SIZE); if (to == from + Long.SIZE) return reverseBytes((to > actualEnd ? 0 : (a[pos + 7] & 0xFFL)) << 56 | @@ -864,20 +898,25 @@ public class TransformationStrategies { (a[pos + 5] & 0xFFL) << 40 | (a[pos + 4] & 0xFFL) << 32 | (a[pos + 3] & 0xFFL) << 24 | - (a[pos + 2] & 0xFF) << 16 | - (a[pos + 1] & 0xFF) << 8 | - (a[pos] & 0xFF)); + (a[pos + 2] & 0xFFL) << 16 | (a[pos + 1] & 0xFFL) << 8 | (a[pos] & 0xFFL)); if ((to & BYTE_MASK) == 0) { long word = 0; switch ((int)((Math.min(actualEnd, to) - Math.min(actualEnd, from)) >>> LOG2_BYTE_SIZE)) { - case 7: word |= (a[pos + 6] & 0xFFL) << 48; - case 6: word |= (a[pos + 5] & 0xFFL) << 40; - case 5: word |= (a[pos + 4] & 0xFFL) << 32; - case 4: word |= (a[pos + 3] & 0xFFL) << 24; - case 3: word |= (a[pos + 2] & 0xFF) << 16; - case 2: word |= (a[pos + 1] & 0xFF) << 8; - case 1: word |= a[pos] & 0xFF; + case 7: + word |= (a[pos + 6] & 0xFFL) << 48; + case 6: + word |= (a[pos + 5] & 0xFFL) << 40; + case 5: + word |= (a[pos + 4] & 0xFFL) << 32; + case 4: + word |= (a[pos + 3] & 0xFFL) << 24; + case 3: + word |= (a[pos + 2] & 0xFFL) << 16; + case 2: + word |= (a[pos + 1] & 0xFFL) << 8; + case 1: + word |= a[pos] & 0xFFL; } return reverseBytes(word); } @@ -888,7 +927,7 @@ public class TransformationStrategies { if (l == Long.SIZE) return 0; if (startBit <= l) return getLong(startPos, Math.min(length, startPos + Long.SIZE)) << l - startBit >>> l; - return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << Long.SIZE + l - startBit >>> l; + return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << l - startBit >>> l; } @Override @@ -962,6 +1001,7 @@ public class TransformationStrategies { public long getLong(final long from, final long to) { final int startBit = (int)(from & BYTE_MASK); if (startBit == 0) { + final byte[] a = this.a; if (to == from + Long.SIZE) { final int pos = (int)(from >>> LOG2_BYTE_SIZE); return (a[pos + 7] & 0xFFL) << 56 | @@ -969,22 +1009,27 @@ public class TransformationStrategies { (a[pos + 5] & 0xFFL) << 40 | (a[pos + 4] & 0xFFL) << 32 | (a[pos + 3] & 0xFFL) << 24 | - (a[pos + 2] & 0xFF) << 16 | - (a[pos + 1] & 0xFF) << 8 | - (a[pos] & 0xFF); + (a[pos + 2] & 0xFFL) << 16 | (a[pos + 1] & 0xFFL) << 8 | (a[pos] & 0xFFL); } if ((to & BYTE_MASK) == 0) { final int pos = (int)(from >>> LOG2_BYTE_SIZE); long word = 0; switch ((int)((to - from) >>> LOG2_BYTE_SIZE)) { - case 7: word |= (a[pos + 6] & 0xFFL) << 48; - case 6: word |= (a[pos + 5] & 0xFFL) << 40; - case 5: word |= (a[pos + 4] & 0xFFL) << 32; - case 4: word |= (a[pos + 3] & 0xFFL) << 24; - case 3: word |= (a[pos + 2] & 0xFF) << 16; - case 2: word |= (a[pos + 1] & 0xFF) << 8; - case 1: word |= (a[pos] & 0xFF); + case 7: + word |= (a[pos + 6] & 0xFFL) << 48; + case 6: + word |= (a[pos + 5] & 0xFFL) << 40; + case 5: + word |= (a[pos + 4] & 0xFFL) << 32; + case 4: + word |= (a[pos + 3] & 0xFFL) << 24; + case 3: + word |= (a[pos + 2] & 0xFFL) << 16; + case 2: + word |= (a[pos + 1] & 0xFFL) << 8; + case 1: + word |= (a[pos] & 0xFFL); } return word; } @@ -996,7 +1041,7 @@ public class TransformationStrategies { if (l == Long.SIZE) return 0; if (startBit <= l) return getLong(startPos, Math.min(length, startPos + Long.SIZE)) << l - startBit >>> l; - return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << Long.SIZE + l - startBit >>> l; + return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << l - startBit >>> l; } @Override @@ -1023,7 +1068,7 @@ public class TransformationStrategies { } } - private static final TransformationStrategy<byte[]> BYTE_ARRAY = new ByteArrayTransformationStrategy(); + private static final TransformationStrategy<byte[]> BYTE_ARRAY = new ByteArrayTransformationStrategy(false); /** A lexicographical transformation from byte arrays to bit vectors. * @@ -1036,8 +1081,40 @@ public class TransformationStrategies { return BYTE_ARRAY; } + private static final TransformationStrategy<byte[]> PREFIX_FREE_BYTE_ARRAY = new ByteArrayTransformationStrategy(true); + + /** + * A lexicographical transformation from byte arrays to bit vectors that completes the + * representation with a zero to guarantee lexicographical ordering and prefix-freeness provided the + * byte arrays to not contain zeros. + * + * <p> + * This transformation is mainly intended for byte arrays representing ASCII strings in compact + * form. + * + * <p> + * <strong>Warning</strong>: bit vectors returned by this strategy are adaptors around the original + * array. If the array changes while the bit vector is being accessed, the results will be + * unpredictable. + * + * @see TransformationStrategies + */ + public static TransformationStrategy<byte[]> prefixFreeByteArray() { + return PREFIX_FREE_BYTE_ARRAY; + } + private static class ByteArrayTransformationStrategy implements TransformationStrategy<byte[]>, Serializable { private static final long serialVersionUID = 1L; + /** Whether we should guarantee prefix-freeness by adding 0 to the end of each byte array. */ + private final boolean prefixFree; + + /** Creates an ISO transformation strategy. The strategy will map a string to the lowest eight bits of its natural UTF16 bit sequence. + * + * @param prefixFree if true, the resulting set of binary words will be made prefix free by adding a NUL at the end of the string. + */ + protected ByteArrayTransformationStrategy(final boolean prefixFree) { + this.prefixFree = prefixFree; + } @Override public long length(final byte[] a) { @@ -1050,15 +1127,18 @@ public class TransformationStrategies { private static final long BYTE_MASK = Byte.SIZE - 1; private final byte[] a; private final long length; + private final long actualEnd; - public ByteArrayBitVector(final byte[] a) { + public ByteArrayBitVector(final byte[] a, final boolean prefixFree) { this.a = a; - length = a.length * (long)Byte.SIZE; + actualEnd = a.length * (long)Byte.SIZE; + length = actualEnd + (prefixFree ? Byte.SIZE : 0); } @Override public boolean getBoolean(final long index) { if (index > length) throw new IndexOutOfBoundsException(); + if (index >= actualEnd) return false; return (a[(int)(index >>> LOG2_BYTE_SIZE)] & 0x80 >> (index & BYTE_MASK)) != 0; } @@ -1066,41 +1146,46 @@ public class TransformationStrategies { public long getLong(final long from, final long to) { final int startBit = (int)(from & BYTE_MASK); if (startBit == 0) { + final byte[] a = this.a; if (to == from + Long.SIZE) { final int pos = (int)(from >>> LOG2_BYTE_SIZE); - return reverseBytes((a[pos + 7] & 0xFFL) << 56 | + return reverseBytes((to > actualEnd ? 0 : (a[pos + 7] & 0xFFL)) << 56 | (a[pos + 6] & 0xFFL) << 48 | (a[pos + 5] & 0xFFL) << 40 | (a[pos + 4] & 0xFFL) << 32 | (a[pos + 3] & 0xFFL) << 24 | - (a[pos + 2] & 0xFF) << 16 | - (a[pos + 1] & 0xFF) << 8 | - (a[pos] & 0xFF)); + (a[pos + 2] & 0xFFL) << 16 | (a[pos + 1] & 0xFFL) << 8 | (a[pos] & 0xFFL)); } if ((to & BYTE_MASK) == 0) { final int pos = (int)(from >>> LOG2_BYTE_SIZE); long word = 0; - switch ((int)((to - from) >>> LOG2_BYTE_SIZE)) { - case 7: word |= (a[pos + 6] & 0xFFL) << 48; - case 6: word |= (a[pos + 5] & 0xFFL) << 40; - case 5: word |= (a[pos + 4] & 0xFFL) << 32; - case 4: word |= (a[pos + 3] & 0xFFL) << 24; - case 3: word |= (a[pos + 2] & 0xFF) << 16; - case 2: word |= (a[pos + 1] & 0xFF) << 8; - case 1: word |= (a[pos] & 0xFF); + switch ((int)((Math.min(actualEnd, to) - Math.min(actualEnd, from)) >>> LOG2_BYTE_SIZE)) { + case 7: + word |= (a[pos + 6] & 0xFFL) << 48; + case 6: + word |= (a[pos + 5] & 0xFFL) << 40; + case 5: + word |= (a[pos + 4] & 0xFFL) << 32; + case 4: + word |= (a[pos + 3] & 0xFFL) << 24; + case 3: + word |= (a[pos + 2] & 0xFFL) << 16; + case 2: + word |= (a[pos + 1] & 0xFFL) << 8; + case 1: + word |= (a[pos] & 0xFFL); } return reverseBytes(word); } } - // Actually, we should never get here as the transformation is not lexicographical. final long l = Long.SIZE - (to - from); final long startPos = from - startBit; if (l == Long.SIZE) return 0; if (startBit <= l) return getLong(startPos, Math.min(length, startPos + Long.SIZE)) << l - startBit >>> l; - return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << Long.SIZE + l - startBit >>> l; + return getLong(startPos, startPos + Long.SIZE) >>> startBit | getLong(startPos + Long.SIZE, Math.min(length, startPos + 2 * Long.SIZE)) << l - startBit >>> l; } @Override @@ -1111,7 +1196,7 @@ public class TransformationStrategies { @Override public BitVector toBitVector(final byte[] s) { - return new ByteArrayBitVector(s); + return new ByteArrayBitVector(s, prefixFree); } @Override @@ -1123,7 +1208,7 @@ public class TransformationStrategies { } private Object readResolve() { - return BYTE_ARRAY; + return prefixFree ? PREFIX_FREE_BYTE_ARRAY : BYTE_ARRAY; } } diff --git a/src/it/unimi/dsi/bits/TransformationStrategy.java b/src/it/unimi/dsi/bits/TransformationStrategy.java index 1c839a457743572fa957dd2c30242e17341ef1d0..4de5eccda67e78c8bef1a1a7a339df2dc39c7936 100644 --- a/src/it/unimi/dsi/bits/TransformationStrategy.java +++ b/src/it/unimi/dsi/bits/TransformationStrategy.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/src/it/unimi/dsi/bits/package-info.java b/src/it/unimi/dsi/bits/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..0b35e3f02030970c95c01931b6f67a7a96cdc8ab --- /dev/null +++ b/src/it/unimi/dsi/bits/package-info.java @@ -0,0 +1,15 @@ +/** Main classes manipulating bits + * + * <p>The {@link it.unimi.dsi.bits.BitVector} interface is the basis for bit vector manipulation. + * The {@link it.unimi.dsi.bits.LongArrayBitVector} implementation is its main implementation. + * The idea is to offer an efficent but easy-to-use bit-vector class by allowing access under many different <em>views</em>. For instance, + * a bit vector can be seen as a {@link it.unimi.dsi.fastutil.longs.LongBigList} of integers of fixed width. Or as a sorted set of + * integers, where the positions of the bits set to one represent elements. + * + * <p>Whenever another object has to be turned into a bit string, you can provide a + * {@link it.unimi.dsi.bits.TransformationStrategy} to that purpose. The static container + * {@link it.unimi.dsi.bits.TransformationStrategies} has several ready-made transformations, + * and some useful wrapping methods. + */ + +package it.unimi.dsi.bits; diff --git a/src/it/unimi/dsi/bits/package.html b/src/it/unimi/dsi/bits/package.html deleted file mode 100644 index 827dc32ff452f2e386b5f3d0d7ba3eb8eb1ebbad..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/bits/package.html +++ /dev/null @@ -1,22 +0,0 @@ -<html> -<head><title>Main classes manipulating bits</title></head> -<body> -<p>Main classes manipulating bits. - -<h2>Package Specification</h2> - -<p>The {@link it.unimi.dsi.bits.BitVector} interface is the basis for bit vector manipulation. -The {@link it.unimi.dsi.bits.LongArrayBitVector} implementation is its main implementation. -The idea is to offer an efficent but easy-to-use bit-vector class by allowing access under many different <em>views</em>. For instance, -a bit vector can be seen as a {@link it.unimi.dsi.fastutil.longs.LongBigList} of integers of fixed width. Or as a sorted set of -integers, where the positions of the bits set to one represent elements. - -<p>Whenever another object has to be turned into a bit string, you can provide a -{@link it.unimi.dsi.bits.TransformationStrategy} to that purpose. The static container -{@link it.unimi.dsi.bits.TransformationStrategies} has several ready-made transformations, -and some useful wrapping methods. - -<p><strong>Warning</strong>: implementing all features of {@link it.unimi.dsi.bits.LongArrayBitVector} has not been easy. There may be bugs. - -</body> -</html> diff --git a/src/it/unimi/dsi/compression/CanonicalFast64CodeWordDecoder.java b/src/it/unimi/dsi/compression/CanonicalFast64CodeWordDecoder.java index ad0a81a3e0ce4c29725f98c5e1dd243839230251..6db793a0264fed299174440ce000a1cef696539b 100644 --- a/src/it/unimi/dsi/compression/CanonicalFast64CodeWordDecoder.java +++ b/src/it/unimi/dsi/compression/CanonicalFast64CodeWordDecoder.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/CodeWordCoder.java b/src/it/unimi/dsi/compression/CodeWordCoder.java index 9f1e97081e15850c2140e120746b250c07e37f74..0cb689ccaaf07a99c8e8ec372ea6686ec00b9ce8 100644 --- a/src/it/unimi/dsi/compression/CodeWordCoder.java +++ b/src/it/unimi/dsi/compression/CodeWordCoder.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/Codec.java b/src/it/unimi/dsi/compression/Codec.java index 981d652910f3611b333835ddf9ac58e3d7a52d97..623a7b769a672f920818d7edcb65f7cbe11b1aac 100644 --- a/src/it/unimi/dsi/compression/Codec.java +++ b/src/it/unimi/dsi/compression/Codec.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/Coder.java b/src/it/unimi/dsi/compression/Coder.java index 9e46673f7c84b02b66b83622401e29dd194e8fcb..b435e9d5daf31ff7488bc726450b63b2ba885dae 100644 --- a/src/it/unimi/dsi/compression/Coder.java +++ b/src/it/unimi/dsi/compression/Coder.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/Decoder.java b/src/it/unimi/dsi/compression/Decoder.java index b15b96c8a3c24d7f3e9bbfd7044e69fbda032bd3..533db9203e56c9dcbdb153b7e5f060887b54912b 100644 --- a/src/it/unimi/dsi/compression/Decoder.java +++ b/src/it/unimi/dsi/compression/Decoder.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/Fast64CodeWordCoder.java b/src/it/unimi/dsi/compression/Fast64CodeWordCoder.java index 37c8e62ff407b9906780f69806386c6ada368266..5b4eaf417ab440760d9459f13aea53fa0beb394d 100644 --- a/src/it/unimi/dsi/compression/Fast64CodeWordCoder.java +++ b/src/it/unimi/dsi/compression/Fast64CodeWordCoder.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/HuTuckerCodec.java b/src/it/unimi/dsi/compression/HuTuckerCodec.java index 4d08c6dc265fd2766e67876c3b422dd1626fd7d2..3106e99eee6f7790b038db0afb645a180cb52f01 100644 --- a/src/it/unimi/dsi/compression/HuTuckerCodec.java +++ b/src/it/unimi/dsi/compression/HuTuckerCodec.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/HuffmanCodec.java b/src/it/unimi/dsi/compression/HuffmanCodec.java index bf877a38679ab6db2a98b3a6ad5de93cb8dab243..ad1d93c1f3f942d2c1e0c49f12ec952ba6ca596e 100644 --- a/src/it/unimi/dsi/compression/HuffmanCodec.java +++ b/src/it/unimi/dsi/compression/HuffmanCodec.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/PrefixCodec.java b/src/it/unimi/dsi/compression/PrefixCodec.java index f36e2b7faa31e2a13bd00f0cb21bb4f2a568f93b..508cc406de715c97048a05af87153fa8a02ad5c6 100644 --- a/src/it/unimi/dsi/compression/PrefixCodec.java +++ b/src/it/unimi/dsi/compression/PrefixCodec.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/PrefixCoder.java b/src/it/unimi/dsi/compression/PrefixCoder.java index f482b45bcfc27da7493b2fe398a334ce7516cb9f..86098e3b20472ffb715c367dcf110212b3ce16d8 100644 --- a/src/it/unimi/dsi/compression/PrefixCoder.java +++ b/src/it/unimi/dsi/compression/PrefixCoder.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/TreeDecoder.java b/src/it/unimi/dsi/compression/TreeDecoder.java index 840679f59d98099fe8091cf4b2317f784c566d12..327615c578ad3473c63c7779eb79511df162736b 100644 --- a/src/it/unimi/dsi/compression/TreeDecoder.java +++ b/src/it/unimi/dsi/compression/TreeDecoder.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/package-info.java b/src/it/unimi/dsi/compression/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..0ca6e9e4f6b297f6d5b84b09bd63f70d7c18e2ef --- /dev/null +++ b/src/it/unimi/dsi/compression/package-info.java @@ -0,0 +1,10 @@ +/** Word-based compression/decompression classes + * + * <p>Classes in this package provide interfaces for the compression system, and implementations + * for codeword-based compression. Their main usage is the construction of + * {@linkplain it.unimi.dsi.util.ImmutableExternalPrefixMap prefix maps}, but + * they are also used, for instance, for <a href="http://webgraph.di.unimi.it/">WebGraph</a> label + * compression. + */ + +package it.unimi.dsi.compression; diff --git a/src/it/unimi/dsi/compression/package.html b/src/it/unimi/dsi/compression/package.html deleted file mode 100644 index aa380d27f746318e96693ac71483f056a5cceac5..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/compression/package.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>Word-based compression/decompression classes</title> - </head> -<body> - -<p>Word-based compression/decompression classes. - -<h2>Package Specification</h2> - -<p>Classes in this package provide interfaces for the compression system, and implementations -for codeword-based compression. Their main usage is the construction of -{@linkplain it.unimi.dsi.util.ImmutableExternalPrefixMap prefix maps}, but -they are also used, for instance, for <a href="http://webgraph.dsi.unimi.it/">WebGraph</a> label -compression. -</body> -</html> diff --git a/src/it/unimi/dsi/io/ByteBufferInputStream.java b/src/it/unimi/dsi/io/ByteBufferInputStream.java index 1a2124a1f78aea964caa1125f77919203b0d7051..cb70cc97d7a2b470fb0da1aba4e59966c6b27e0d 100644 --- a/src/it/unimi/dsi/io/ByteBufferInputStream.java +++ b/src/it/unimi/dsi/io/ByteBufferInputStream.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/ByteDiskQueue.java b/src/it/unimi/dsi/io/ByteDiskQueue.java index 3231cc26f3944b8b561d1cc5771dd84572890c0e..a125510b04161af46870ac79995e5dcdb15abd37 100644 --- a/src/it/unimi/dsi/io/ByteDiskQueue.java +++ b/src/it/unimi/dsi/io/ByteDiskQueue.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/DebugInputBitStream.java b/src/it/unimi/dsi/io/DebugInputBitStream.java index 264a4b510613bdbdba9fa73fd1556ad087bcfb67..b29626bb0ff465344534b012375c7f318dec8fd7 100644 --- a/src/it/unimi/dsi/io/DebugInputBitStream.java +++ b/src/it/unimi/dsi/io/DebugInputBitStream.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2006-2020 Sebastiano Vigna + * Copyright (C) 2006-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/DebugOutputBitStream.java b/src/it/unimi/dsi/io/DebugOutputBitStream.java index e162516ed09cb3b4cea7a4f8cb19e5383c069877..a168f0e78681c53e905fa2b067491b6c4753fcb7 100644 --- a/src/it/unimi/dsi/io/DebugOutputBitStream.java +++ b/src/it/unimi/dsi/io/DebugOutputBitStream.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2006-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2006-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/DelimitedWordReader.java b/src/it/unimi/dsi/io/DelimitedWordReader.java index 5f055fe77d2b389d97a3d9d841ce830f71b0437e..7a31164c055b989efd969191a0ab0d1775416e89 100644 --- a/src/it/unimi/dsi/io/DelimitedWordReader.java +++ b/src/it/unimi/dsi/io/DelimitedWordReader.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2009-2020 Sebastiano Vigna + * Copyright (C) 2009-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/FastBufferedReader.java b/src/it/unimi/dsi/io/FastBufferedReader.java index f4251d29ff2a37799a8cabbf76efc7ab308b290d..7d3e24f75dcf316461eb8f2aad8659b939cb93f5 100644 --- a/src/it/unimi/dsi/io/FastBufferedReader.java +++ b/src/it/unimi/dsi/io/FastBufferedReader.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/FileLinesByteArrayIterable.java b/src/it/unimi/dsi/io/FileLinesByteArrayIterable.java new file mode 100644 index 0000000000000000000000000000000000000000..a2096cdb8a52234b454f108316a755284dca2553 --- /dev/null +++ b/src/it/unimi/dsi/io/FileLinesByteArrayIterable.java @@ -0,0 +1,334 @@ +/* + * DSI utilities + * + * Copyright (C) 2020-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.io; + +import java.io.Closeable; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.util.Arrays; +import java.util.EnumSet; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.zip.GZIPInputStream; + +import it.unimi.dsi.fastutil.BigList; +import it.unimi.dsi.fastutil.Size64; +import it.unimi.dsi.fastutil.bytes.ByteArrays; +import it.unimi.dsi.fastutil.io.FastBufferedInputStream; +import it.unimi.dsi.fastutil.io.FastBufferedInputStream.LineTerminator; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import it.unimi.dsi.fastutil.objects.ObjectBigArrayBigList; +import it.unimi.dsi.fastutil.objects.ObjectIterables; +import it.unimi.dsi.fastutil.objects.ObjectList; + +/** + * A wrapper exhibiting the lines of a file as an {@link Iterable} of byte arrays. + * + * <P> + * An instance of this class makes it possible to access the lines of a file as an {@link Iterable} + * of byte arrays. Reading is performed using + * {@link FastBufferedInputStream#readLine(byte[], EnumSet)}, and follows the rules defined therein. + * No decoding is performed. + * + * <P> + * The result of a call to {@link #iterator()} can be used to scan the file; each call will open an + * independent input stream. The returned iterator type + * ({@link it.unimi.dsi.io.FileLinesByteArrayIterable.FileLinesIterator FileLinesIterator}) is + * {@link java.io.Closeable}, and should be closed after usage. Exhausted iterators, however, will + * be closed automagically. + * + * <p> + * Using a suitable {@linkplain #FileLinesByteArrayIterable(String, long, Class) constructor} it is + * possible to specify a decompression class, which must extend {@link InputStream} and provide a + * constructor accepting an {@link InputStream} (e.g., {@link GZIPInputStream} if the file is + * compressed in <code>gzip</code> format). + * + * <p> + * Convenience {@linkplain #iterator(InputStream, Class, EnumSet) static methods} makes it possible + * to build on the fly an iterator over an input stream using the same conventions. + * + * <p> + * This class implements {@link #size64()}, which will return the number of lines of the file, + * computed with a full scan at the first invocation. However, it is also possible to specify at + * construction time the number of lines in the file to skip the first scan. It is responsibility of + * the caller that the specified size and the actual number of lines in the file do match. + * + * @author Sebastiano Vigna + * @since 2.6.17 + */ +public class FileLinesByteArrayIterable implements Iterable<byte[]>, Size64 { + /** The filename upon which this file-lines collection is based. */ + private final String filename; + /** + * A constructor for a stream decompressor for this iterable, or {@code null} for no compression. + */ + private final Constructor<? extends InputStream> decompressor; + /** A set of terminators for the underlying {@link FastBufferedInputStream}. */ + private final EnumSet<LineTerminator> terminators; + /** The cached size of this iterable. */ + private long size = -1; + + /** + * Creates a file-lines byte-array iterable for the specified filename. + * + * @param filename a filename. + */ + public FileLinesByteArrayIterable(final String filename) { + this(filename, -1); + } + + /** + * Creates a file-lines byte-array iterable for the specified filename and size. + * + * @param filename a filename. + * @param size the number of lines in the file. + */ + public FileLinesByteArrayIterable(final String filename, final long size) { + this(filename, size, FastBufferedInputStream.ALL_TERMINATORS); + } + + /** + * Creates a file-lines byte-array iterable for the specified filename and size using the given line + * terminators. + * + * @param filename a filename. + * @param size the number of lines in the file. + * @param terminators line terminators for the underlying {@link FastBufferedInputStream}. + */ + public FileLinesByteArrayIterable(final String filename, final long size, final EnumSet<LineTerminator> terminators) { + this.filename = filename; + this.size = size; + this.terminators = terminators; + this.decompressor = null; + } + + /** + * Creates a file-lines byte-array iterable for the specified filename, optionally assuming that the + * file is compressed. + * + * @param filename a filename. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + */ + public FileLinesByteArrayIterable(final String filename, final Class<? extends InputStream> decompressor) throws NoSuchMethodException, SecurityException { + this(filename, -1, decompressor); + } + + /** + * Creates a file-lines byte-array iterable for the specified filename and size, optionally assuming + * that the file is compressed. + * + * @param filename a filename. + * @param size the number of lines in the file. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + */ + public FileLinesByteArrayIterable(final String filename, final long size, final Class<? extends InputStream> decompressor) throws NoSuchMethodException, SecurityException { + this(filename, size, FastBufferedInputStream.ALL_TERMINATORS, decompressor); + } + + /** + * Creates a file-lines byte-array iterable for the specified filename and size using the given line + * terminators and optionally assuming that the file is compressed. + * + * @param filename a filename. + * @param size the number of lines in the file. + * @param terminators line terminators for the underlying {@link FastBufferedInputStream}. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + */ + public FileLinesByteArrayIterable(final String filename, final long size, final EnumSet<LineTerminator> terminators, final Class<? extends InputStream> decompressor) throws NoSuchMethodException, SecurityException { + this.filename = filename; + this.size = size; + this.terminators = terminators; + this.decompressor = decompressor != null ? decompressor.getConstructor(InputStream.class) : null; + } + + + /** + * An iterator over the lines of a {@link FileLinesByteArrayIterable}. + * + * <p> + * Instances of this class open an {@link java.io.InputStream}, and thus should be + * {@linkplain Closeable#close() closed} after usage. A “safety-net” finaliser tries to + * take care of the cases in which closing an instance is impossible. An exhausted iterator, + * however, will be closed automagically. + */ + + public static final class FileLinesIterator implements Iterator<byte[]>, SafelyCloseable { + private final EnumSet<LineTerminator> terminators; + private FastBufferedInputStream fbis; + private byte[] buffer = new byte[1024]; + private boolean ready; + private int read; + + private FileLinesIterator(final InputStream ibs, final EnumSet<LineTerminator> terminators) { + this.fbis = new FastBufferedInputStream(ibs); + this.terminators = terminators; + } + + @Override + public boolean hasNext() { + if (ready) return true; + if (fbis == null) return false; + ready = false; + try { + read = 0; + int len; + while((len = fbis.readLine(buffer, read, buffer.length - read, terminators)) == buffer.length - read) { + ready = true; + read += len; + buffer = ByteArrays.grow(buffer, buffer.length + 1); + } + if (len != -1) { + ready = true; + read += len; + } + if (len == -1) close(); + } catch (final IOException e) { + throw new RuntimeException(e); + } + + return ready; + } + + @Override + public byte[] next() { + if (! hasNext()) throw new NoSuchElementException(); + ready = false; + return Arrays.copyOf(buffer, read); + } + + @Override + public synchronized void close() { + if (fbis == null) return; + try { + fbis.close(); + } + catch (final IOException e) { + throw new RuntimeException(e); + } + finally { + fbis = null; + } + } + + @SuppressWarnings("deprecation") + @Override + protected synchronized void finalize() throws Throwable { + try { + if (fbis != null) close(); + } + finally { + super.finalize(); + } + } + } + + @Override + public FileLinesIterator iterator() { + try { + final InputStream inputStream = decompressor == null ? new FileInputStream(filename) : decompressor.newInstance(new FileInputStream(filename)); + return new FileLinesIterator(inputStream, terminators); + } catch (final Exception e) { + throw new RuntimeException(e); + } + } + + /** + * A convenience method returning a one-off {@link FileLinesIterator} reading from an input stream. + * + * @param inputStream an input stream. + * @return an iterator returning the lines contained in the provided input stream. + */ + public static FileLinesIterator iterator(final InputStream inputStream) { + return iterator(inputStream, null); + } + + /** + * A convenience method returning a one-off {@link FileLinesIterator} reading from an input stream. + * + * @param inputStream an input stream. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + * @return an iterator returning the lines contained in the provided input stream. + */ + public static FileLinesIterator iterator(final InputStream inputStream, final Class<? extends InputStream> decompressor) { + return iterator(inputStream, decompressor, FastBufferedInputStream.ALL_TERMINATORS); + } + + /** + * A convenience method returning a one-off {@link FileLinesIterator} reading from an input stream. + * + * @param inputStream an input stream. + * @param terminators line terminators for the underlying {@link FastBufferedInputStream}. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + * @return an iterator returning the lines contained in the provided input stream. + */ + public static FileLinesIterator iterator(InputStream inputStream, final Class<? extends InputStream> decompressor, final EnumSet<LineTerminator> terminators) { + try { + if (decompressor != null) inputStream = decompressor.getConstructor(InputStream.class).newInstance(inputStream); + return new FileLinesIterator(inputStream, terminators); + } catch (final Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public synchronized long size64() { + if (size == -1) size = ObjectIterables.size(this); + return size; + } + + /** + * Returns all lines as a {@linkplain java.util.List list}. + * + * @implSpec This method iterates over the lines of the file and accumulates the resulting byte + * arrays in a standard list. Thus, it will throw an exception on files with more than + * {@link Integer#MAX_VALUE} lines. + * + * @return all lines of the file wrapped by this file-lines byte-array iterable. + * @see #allLinesBig() + */ + public ObjectList<byte[]> allLines() { + final ObjectArrayList<byte[]> result = new ObjectArrayList<>(); + for (final byte[] a : this) result.add(a); + return result; + } + + /** + * Returns all lines as a {@linkplain BigList big list}. + * + * @implSpec This method iterates over the lines of the file and accumulates the resulting byte + * arrays. in a {@linkplain BigList big list}. Thus, it supports files with more than + * {@link Integer#MAX_VALUE} lines. + * + * @return all lines of the file wrapped by this file-lines byte-array iterable. + * @see #allLines() + */ + public ObjectBigArrayBigList<byte[]> allLinesBig() { + final ObjectBigArrayBigList<byte[]> result = new ObjectBigArrayBigList<>(); + for (final byte[] a : this) result.add(a); + return result; + } +} diff --git a/src/it/unimi/dsi/io/FileLinesCollection.java b/src/it/unimi/dsi/io/FileLinesCollection.java index 58e30a251d8eb4894cbe6901f9b1a07c1f0c41a5..8e8a8f1c844175159ab1060c87b9f1d47619e749 100644 --- a/src/it/unimi/dsi/io/FileLinesCollection.java +++ b/src/it/unimi/dsi/io/FileLinesCollection.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; @@ -34,37 +33,47 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; import it.unimi.dsi.lang.MutableString; -/** A wrapper exhibiting the lines of a file as a {@link java.util.Collection}. +/** + * A wrapper exhibiting the lines of a file as a {@link java.util.Collection}. + * + * <P> + * <strong>Warning</strong>: the lines returned by iterators generated by instances of this class + * <em>are not cacheable</em>. The returned value is a {@link it.unimi.dsi.lang.MutableString} + * instance that is reused at each call, and that is <em>modified by a call to + * {@link java.util.Iterator#hasNext() hasNext()}</em>. Thus, for instance, * - * <P><strong>Warning</strong>: the lines returned by iterators generated by - * instances of this class <em>are not cacheable</em>. The returned value is - * a {@link it.unimi.dsi.lang.MutableString} instance that is reused - * at each call, and that is <em>modified by a call to {@link java.util.Iterator#hasNext() hasNext()}</em>. - * Thus, for instance, * <pre> - * ObjectIterators.unwrap(fileLinesColletion.iterator()); + * ObjectIterators.unwrap(fileLinesColletion.iterator()); * </pre> - * will not give the expected results. Use {@link #allLines()} to get - * the list of all lines (again, under the form of compact {@link it.unimi.dsi.lang.MutableString}s). - * Note also that {@link #toString()} will return a single string containing all - * file lines separated by the string associated with the system property <code>line.separator</code>. * - * <P>An instance of this class allows to access the lines of a file as a - * {@link java.util.Collection}. Using {@linkplain java.util.Collection#contains(java.lang.Object) - * direct access} is strongly discouraged (it will require a full scan of the file), but - * the {@link #iterator()} can be fruitfully used to scan the file, and can be called any - * number of times, as it opens an independent input stream at each call. For the - * same reason, the returned iterator type ({@link it.unimi.dsi.io.FileLinesCollection.FileLinesIterator}) - * is {@link java.io.Closeable}, and should be closed after usage. + * will not give the expected results. Use {@link #allLines()} to get the list of all lines (again, + * under the form of compact {@link it.unimi.dsi.lang.MutableString}s). Note also that + * {@link #toString()} will return a single string containing all file lines separated by the string + * associated with the system property <code>line.separator</code>. * - * <p>Using a suitable {@linkplain #FileLinesCollection(CharSequence, String, boolean) constructor}, it is possible - * to specify that the file is compressed in <code>gzip</code> format (in this case, it will be opened using a {@link GZIPInputStream}). + * <P> + * An instance of this class allows to access the lines of a file as a {@link java.util.Collection}. + * Using {@linkplain java.util.Collection#contains(java.lang.Object) direct access} is strongly + * discouraged (it will require a full scan of the file), but the {@link #iterator()} can be + * fruitfully used to scan the file, and can be called any number of times, as it opens an + * independent input stream at each call. For the same reason, the returned iterator type + * ({@link it.unimi.dsi.io.FileLinesCollection.FileLinesIterator}) is {@link java.io.Closeable}, and + * should be closed after usage. * - * <P>Note that the first call to {@link #size()} will require a full file scan. + * <p> + * Using a suitable {@linkplain #FileLinesCollection(CharSequence, String, boolean) constructor}, it + * is possible to specify that the file is compressed in <code>gzip</code> format (in this case, it + * will be opened using a {@link GZIPInputStream}). + * + * <P> + * Note that the first call to {@link #size()} will require a full file scan. * * @author Sebastiano Vigna * @since 0.9.2 + * @deprecated Please use {@link FileLinesMutableStringIterable} instead; the {@code zipped} option of this class + * can be simulated by passing a {@link GZIPInputStream} as decompressor. */ +@Deprecated public class FileLinesCollection extends AbstractCollection<MutableString> { /** The filename upon which this file-lines collection is based. */ private final String filename; @@ -98,13 +107,22 @@ public class FileLinesCollection extends AbstractCollection<MutableString> { } - /** An iterator over the lines of a {@link FileLinesCollection}. + /** + * An iterator over the lines of a {@link FileLinesCollection}. + * + * <p> + * Instances of this class open an {@link java.io.InputStream}, and thus should be + * {@linkplain Closeable#close() closed} after usage. A “safety-net” finaliser tries to + * take care of the cases in which closing an instance is impossible. An exhausted iterator, + * however, will be closed automagically. * - * <p>Instances of this class open an {@link java.io.InputStream}, and thus should be {@linkplain Closeable#close() closed} after - * usage. A “safety-net” finaliser tries to take care of the cases in which - * closing an instance is impossible. An exhausted iterator, however, will be closed automagically. + * @deprecated Please use + * {@link FileLinesMutableStringIterable#iterator(java.io.InputStream, java.nio.charset.Charset, Class)}; + * the {@code zipped} option of this class can be simulated by passing a + * {@link GZIPInputStream} as decompressor. */ + @Deprecated public static final class FileLinesIterator implements Iterator<MutableString>, SafelyCloseable { private FastBufferedReader fbr; MutableString s = new MutableString(), next; @@ -162,7 +180,6 @@ public class FileLinesCollection extends AbstractCollection<MutableString> { } } - @SuppressWarnings("deprecation") @Override protected synchronized void finalize() throws Throwable { try { diff --git a/src/it/unimi/dsi/io/FileLinesMutableStringIterable.java b/src/it/unimi/dsi/io/FileLinesMutableStringIterable.java new file mode 100644 index 0000000000000000000000000000000000000000..554e7584ab083444d3a3020d6be5367e88e247f9 --- /dev/null +++ b/src/it/unimi/dsi/io/FileLinesMutableStringIterable.java @@ -0,0 +1,382 @@ +/* + * DSI utilities + * + * Copyright (C) 2020-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.io; + +import java.io.Closeable; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Constructor; +import java.nio.charset.Charset; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.zip.GZIPInputStream; + +import it.unimi.dsi.fastutil.BigList; +import it.unimi.dsi.fastutil.Size64; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import it.unimi.dsi.fastutil.objects.ObjectBigArrayBigList; +import it.unimi.dsi.fastutil.objects.ObjectBigList; +import it.unimi.dsi.fastutil.objects.ObjectIterables; +import it.unimi.dsi.fastutil.objects.ObjectList; +import it.unimi.dsi.lang.MutableString; + +/** + * A wrapper exhibiting the lines of a file as an {@link Iterable} of {@linkplain MutableString + * mutable strings}. + * + * <P> + * <strong>Warning</strong>: the lines returned by iterators generated by instances of this class + * <em>are not cacheable</em>. The returned value is a {@link it.unimi.dsi.lang.MutableString + * MutableString} instance that is reused at each call, and that is <em>modified by a call to + * {@link java.util.Iterator#hasNext() hasNext()}</em>. Thus, for instance, + * + * <pre> + * ObjectIterators.unwrap(fileLinesMutableStringIterable.iterator()); + * </pre> + * + * will not give the expected results. Use {@link #allLines()} or {@link #allLinesBig()} for that + * purpose. + * + * <P> + * The result of a call to {@link #iterator()} can be used to scan the file; each call will open an + * independent input stream. The returned iterator type + * ({@link it.unimi.dsi.io.FileLinesMutableStringIterable.FileLinesIterator FileLinesIterator}) is + * {@link java.io.Closeable}, and should be closed after usage. Exhausted iterators, however, will + * be closed automagically. + * + * <p> + * Using a suitable {@linkplain #FileLinesMutableStringIterable(String, long, Charset, Class) + * constructor} it is possible to specify a decompression class, which must extend + * {@link InputStream} and provide a constructor accepting an {@link InputStream} (e.g., + * {@link GZIPInputStream} if the file is compressed in <code>gzip</code> format). + * + * <p> + * Convenience {@linkplain #iterator(InputStream, Charset, Class) static methods} makes it possible + * to build on the fly an iterator over an input stream using the same conventions. + * + * <p> + * This class implements {@link #size64()}, which will return the number of lines of the file, + * computed with a full scan at the first invocation. However, it is also possible to specify at + * construction time the number of lines in the file to skip the first scan. It is responsibility of + * the caller that the specified size and the actual number of lines in the file do match. + * + * @author Sebastiano Vigna + * @since 2.6.17 + */ +public class FileLinesMutableStringIterable implements Iterable<MutableString>, Size64 { + /** The filename upon which this file-lines iterable is based. */ + private final String filename; + /** The encoding of {@link #filename}. */ + private final Charset encoding; + /** + * A constructor for a stream decompressor for this iterable, or {@code null} for no compression. + */ + private final Constructor<? extends InputStream> decompressor; + /** The cached size of this iterable. */ + private long size = -1; + + /** + * Creates a file-lines iterable for the specified filename using the platform encoding. + * + * @param filename a filename. + */ + public FileLinesMutableStringIterable(final String filename) { + this(filename, -1); + } + + /** + * Creates a file-lines iterable for the specified filename and size using the platform encoding. + * + * @param filename a filename. + * @param size the number of lines in the file. + */ + public FileLinesMutableStringIterable(final String filename, final long size) { + this(filename, size, Charset.defaultCharset()); + } + + /** + * Creates a file-lines iterable for the specified filename using the specified encoding. + * + * @param filename a filename. + * @param encoding an encoding. + */ + public FileLinesMutableStringIterable(final String filename, final Charset encoding) { + this(filename, -1, encoding); + } + + /** + * Creates a file-lines iterable for the specified filename and size using the specified encoding. + * + * @param filename a filename. + * @param size the number of lines in the file. + * @param encoding an encoding. + */ + public FileLinesMutableStringIterable(final String filename, final long size, final Charset encoding) { + this.filename = filename; + this.encoding = encoding; + this.decompressor = null; + this.size = size; + } + + /** + * Creates a file-lines iterable for the specified filename using the specified encoding. + * + * @param filename a filename. + * @param encoding an encoding. + */ + public FileLinesMutableStringIterable(final String filename, final String encoding) { + this(filename, -1, encoding); + } + + /** + * Creates a file-lines iterable for the specified filename and size using the specified encoding. + * + * @param filename a filename. + * @param size the number of lines in the file. + * @param encoding an encoding. + */ + public FileLinesMutableStringIterable(final String filename, final long size, final String encoding) { + this.filename = filename; + this.encoding = Charset.forName(encoding); + this.decompressor = null; + this.size = size; + } + + /** + * Creates a file-lines iterable for the specified filename using the platform encoding, optionally + * assuming that the file is compressed. + * + * @param filename a filename. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + */ + public FileLinesMutableStringIterable(final String filename, final Class<? extends InputStream> decompressor) throws NoSuchMethodException, SecurityException { + this(filename, -1, Charset.defaultCharset(), decompressor); + } + + /** + * Creates a file-lines iterable for the specified filename and size using the platform encoding, + * optionally assuming that the file is compressed. + * + * @param filename a filename. + * @param size the number of lines in the file. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + */ + public FileLinesMutableStringIterable(final String filename, final long size, final Class<? extends InputStream> decompressor) throws NoSuchMethodException, SecurityException { + this(filename, size, Charset.defaultCharset(), decompressor); + } + + /** + * Creates a file-lines iterable for the specified filename with the specified encoding, optionally + * assuming that the file is compressed. + * + * @param filename a filename. + * @param encoding an encoding. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + */ + public FileLinesMutableStringIterable(final String filename, final Charset encoding, final Class<? extends InputStream> decompressor) throws NoSuchMethodException, SecurityException { + this(filename, -1, encoding, decompressor); + } + + /** + * Creates a file-lines iterable for the specified filename with the specified encoding, optionally + * assuming that the file is compressed. + * + * @param filename a filename. + * @param encoding an encoding. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + */ + public FileLinesMutableStringIterable(final String filename, final String encoding, final Class<? extends InputStream> decompressor) throws NoSuchMethodException, SecurityException { + this(filename, -1, Charset.forName(encoding), decompressor); + } + + /** + * Creates a file-lines iterable for the specified filename and size with the specified encoding, + * optionally assuming that the file is compressed. + * + * @param filename a filename. + * @param size the number of lines in the file. + * @param encoding an encoding. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + */ + public FileLinesMutableStringIterable(final String filename, final long size, final Charset encoding, final Class<? extends InputStream> decompressor) throws NoSuchMethodException, SecurityException { + this.filename = filename; + this.encoding = encoding; + this.decompressor = decompressor != null ? decompressor.getConstructor(InputStream.class) : null; + this.size = size; + } + + /** + * An iterator over the lines of a {@link FileLinesMutableStringIterable}. + * + * <p> + * Instances of this class open an {@linkplain java.io.InputStream input stream}, and thus should be + * {@linkplain Closeable#close() closed} after usage. A “safety-net” finaliser tries to + * take care of the cases in which closing an instance is impossible. An exhausted iterator, + * however, will be closed automagically. + */ + + public static final class FileLinesIterator implements Iterator<MutableString>, SafelyCloseable { + private final MutableString s = new MutableString(); + private FastBufferedReader fbr; + private MutableString next; + private boolean toAdvance = true; + + private FileLinesIterator(final FastBufferedReader fbr) { + this.fbr = fbr; + } + + @Override + public boolean hasNext() { + if (toAdvance) { + try { + next = fbr.readLine(s); + if (next == null) close(); + } catch (final IOException e) { + throw new RuntimeException(e); + } + toAdvance = false; + } + + return next != null; + } + + @Override + public MutableString next() { + if (! hasNext()) throw new NoSuchElementException(); + toAdvance = true; + return s; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + @Override + public synchronized void close() { + if (fbr == null) return; + try { + fbr.close(); + } + catch (final IOException e) { + throw new RuntimeException(e); + } + finally { + fbr = null; + } + } + + @SuppressWarnings("deprecation") + @Override + protected synchronized void finalize() throws Throwable { + try { + if (fbr != null) close(); + } + finally { + super.finalize(); + } + } + + } + + @Override + public FileLinesIterator iterator() { + try { + final InputStream inputStream = decompressor == null ? new FileInputStream(filename) : decompressor.newInstance(new FileInputStream(filename)); + return new FileLinesIterator(new FastBufferedReader(new InputStreamReader(inputStream, encoding))); + } catch (final Exception e) { + throw new RuntimeException(e); + } + } + + /** + * A convenience method returning a one-off {@link FileLinesIterator} reading from an input stream. + * + * @param inputStream an input stream. + * @param encoding an encoding. + * @return an iterator returning the lines contained in the provided input stream. + */ + public static FileLinesIterator iterator(final InputStream inputStream, final Charset encoding) { + return iterator(inputStream, encoding, null); + } + + /** + * A convenience method returning a one-off {@link FileLinesIterator} reading from an input stream. + * + * @param inputStream an input stream. + * @param encoding an encoding. + * @param decompressor a class extending {@link InputStream} that will be used as a decompressor, or + * {@code null} for no decompression. + * @return an iterator returning the lines contained in the provided input stream. + */ + public static FileLinesIterator iterator(InputStream inputStream, final Charset encoding, final Class<? extends InputStream> decompressor) { + try { + if (decompressor != null) inputStream = decompressor.getConstructor(InputStream.class).newInstance(inputStream); + return new FileLinesIterator(new FastBufferedReader(new InputStreamReader(inputStream, encoding))); + } catch (final Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public synchronized long size64() { + if (size == -1) size = ObjectIterables.size(this); + return size; + } + + /** + * Returns all lines as a {@linkplain java.util.List list}. + * + * @implSpec This method iterates over the lines of the file and accumulates the resulting strings + * in a standard list. Thus, it will throw an exception on files with more than + * {@link Integer#MAX_VALUE} lines. + * + * @return all lines of the file wrapped by this file-lines collection. + * @see #allLinesBig() + */ + public ObjectList<String> allLines() { + final ObjectArrayList<String> result = new ObjectArrayList<>(); + for (final MutableString s : this) result.add(s.toString()); + return result; + } + + /** + * Returns all lines as a {@linkplain BigList big list}. + * + * @implSpec This method iterates over the lines of the file and accumulates the resulting strings + * in a {@linkplain BigList big list}. Thus, it supports files with more than + * {@link Integer#MAX_VALUE} lines. + * + * @return all lines of the file wrapped by this file-lines collection. + * @see #allLines() + */ + public ObjectBigList<String> allLinesBig() { + final ObjectBigArrayBigList<String> result = new ObjectBigArrayBigList<>(); + for (final MutableString s : this) result.add(s.toString()); + return result; + } +} diff --git a/src/it/unimi/dsi/io/InputBitStream.java b/src/it/unimi/dsi/io/InputBitStream.java index 2509e1ed3b7a99433e5175fe57b968a375f0a888..1b9ee31b31d23472917f7ed665527e5fe0fce422 100644 --- a/src/it/unimi/dsi/io/InputBitStream.java +++ b/src/it/unimi/dsi/io/InputBitStream.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/LineIterator.java b/src/it/unimi/dsi/io/LineIterator.java index 2163c79610e4fbc3f5ac8bcbaaaa39e15d78f6bc..fb685b75407a72835c6ea31e961f648d448dd68d 100644 --- a/src/it/unimi/dsi/io/LineIterator.java +++ b/src/it/unimi/dsi/io/LineIterator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/LineWordReader.java b/src/it/unimi/dsi/io/LineWordReader.java index f0f9e803066887e938298bf805511f4814491e76..d51cf2e045a8a31e95fa5103fd72796f43e02204 100644 --- a/src/it/unimi/dsi/io/LineWordReader.java +++ b/src/it/unimi/dsi/io/LineWordReader.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2006-2020 Sebastiano Vigna + * Copyright (C) 2006-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/MultipleInputStream.java b/src/it/unimi/dsi/io/MultipleInputStream.java index bf02251fada88c6c37dc1d297b6a0e8021d7a68e..fd4bb621848da27b34e6f75e893aec0a735342fc 100644 --- a/src/it/unimi/dsi/io/MultipleInputStream.java +++ b/src/it/unimi/dsi/io/MultipleInputStream.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2003-2020 Sebastiano Vigna + * Copyright (C) 2003-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/NullInputStream.java b/src/it/unimi/dsi/io/NullInputStream.java index 9d482e35a2ee79e8ef6112ad4811207076dd1f45..0dfb0d28c6bab02b4970a503728f1dcdf67f29f8 100644 --- a/src/it/unimi/dsi/io/NullInputStream.java +++ b/src/it/unimi/dsi/io/NullInputStream.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2003-2020 Sebastiano Vigna + * Copyright (C) 2003-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/NullOutputStream.java b/src/it/unimi/dsi/io/NullOutputStream.java index ba7988bf8195abbe0e53c47e3a92d2c095dcabff..136b8f5745c9d6fcfb3b972ad98aea0f6b8e7a37 100644 --- a/src/it/unimi/dsi/io/NullOutputStream.java +++ b/src/it/unimi/dsi/io/NullOutputStream.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2003-2020 Sebastiano Vigna + * Copyright (C) 2003-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/NullReader.java b/src/it/unimi/dsi/io/NullReader.java index 0aa91fc12512a561ff9e4e8fcfcff4ec085733fc..54cb95cab9c1db190c1c3edfe3fbbcbc3ee3dd4a 100644 --- a/src/it/unimi/dsi/io/NullReader.java +++ b/src/it/unimi/dsi/io/NullReader.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2003-2020 Sebastiano Vigna + * Copyright (C) 2003-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/OfflineIterable.java b/src/it/unimi/dsi/io/OfflineIterable.java index f1bcbb54e3b057abfca4e9927b951c3f415361a0..acf3764b2dd32803c020c8783be3f34f5bd5eb42 100644 --- a/src/it/unimi/dsi/io/OfflineIterable.java +++ b/src/it/unimi/dsi/io/OfflineIterable.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/OutputBitStream.java b/src/it/unimi/dsi/io/OutputBitStream.java index f28a625316bdf374130f6401655f743102a2e2ce..f36f6101e1b188cb6353f82d9eaad5a3749daa73 100644 --- a/src/it/unimi/dsi/io/OutputBitStream.java +++ b/src/it/unimi/dsi/io/OutputBitStream.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/SafelyCloseable.java b/src/it/unimi/dsi/io/SafelyCloseable.java index 4f1b262c393825e7bdc5677e61355fcf51b0b13e..16c85589b192304b9d7f1abacbe4068b7918940c 100644 --- a/src/it/unimi/dsi/io/SafelyCloseable.java +++ b/src/it/unimi/dsi/io/SafelyCloseable.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2006-2020 Sebastiano Vigna + * Copyright (C) 2006-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/SegmentedInputStream.java b/src/it/unimi/dsi/io/SegmentedInputStream.java index b0cc7dcbde7e78977eb933757135c1014d94c0bb..eec40e34e34ecff80aa3e838f2aa89abe2e12b99 100644 --- a/src/it/unimi/dsi/io/SegmentedInputStream.java +++ b/src/it/unimi/dsi/io/SegmentedInputStream.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2006-2020 Sebastiano Vigna + * Copyright (C) 2006-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/WordReader.java b/src/it/unimi/dsi/io/WordReader.java index 180d819911d8979ae79f0696818e74f7f011bba1..edb3178e640a0431a64ecea59556f7cea9c2c76f 100644 --- a/src/it/unimi/dsi/io/WordReader.java +++ b/src/it/unimi/dsi/io/WordReader.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2005-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/package-info.java b/src/it/unimi/dsi/io/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..dc72af692a9d84c4001ffff57582b5a181d98e9d --- /dev/null +++ b/src/it/unimi/dsi/io/package-info.java @@ -0,0 +1,39 @@ +/** I/O classes + * + * <p>Classes in this package fulfill needs that are not satisfied by the + * standard I/O classes available. + * + * <h2>Reading text</h2> + * + * <p>We provide replacement classes such as {@link + * it.unimi.dsi.io.FastBufferedReader} and classes exposing the lines of + * a file as an {@linkplain + * it.unimi.dsi.io.FileLinesMutableStringIterable Iterable}. The general + * {@link it.unimi.dsi.io.WordReader} interface is used by <a href="http://mg4j.di.unimi.it/">MG4J</a> + * to provide customizable word segmentation. + * + * <h2>Bit-level I/O</h2> + * + * <P>The standard Java API lacks bit-level I/O classes: to this purpose, we + * provide {@link it.unimi.dsi.io.InputBitStream} and {@link + * it.unimi.dsi.io.OutputBitStream}, which can wrap any standard Java + * corresponding stream and make it work at the bit level; moreover, they + * provide support for several useful formats (such as unary, binary, minimal + * binary, γ, δ and Golomb encoding). + + * <P>Bit input and output streams offer also efficient buffering and a way to + * reposition the bit stream in case the underlying byte stream is a + * file-based stream or a {@link it.unimi.dsi.fastutil.io.RepositionableStream}. + * + * <h2>Conventions</h2> + * + * <p><strong>All coding methods work on natural numbers</strong>. The + * encoding of zero is very natural for some techniques, and much less natural + * for others. To keep methods rationally organized, all methods are able to + * encode any natural number. If, for instance, you want to write positive + * numbers in unary encoding and you do not want to waste a bit, you have to + * decrement them first (i.e., instead of <var>p</var> you must encode + * <var>p</var> − 1). + */ + +package it.unimi.dsi.io; diff --git a/src/it/unimi/dsi/io/package.html b/src/it/unimi/dsi/io/package.html deleted file mode 100644 index 9305439f6fb2ee787a121d3b6b61e3922ff70f9a..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/io/package.html +++ /dev/null @@ -1,48 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>I/O classes</title> - </head> - - <body> - - <P>I/O classes. - - <h2>Package Specification</h2> - - <p>Classes in this package fulfill needs that are not satisfied by the - I/O classes available. - - <h3>Reading text</h3> - - <p>We provide replacement classes such as {@link it.unimi.dsi.io.FastBufferedReader} - and classes exposing the lines of a file as a {@linkplain it.unimi.dsi.io.FileLinesCollection collection} - or as an {@linkplain it.unimi.dsi.io.LineIterator iterator}. The general - {@link it.unimi.dsi.io.WordReader} interface is used by - <a href="http://mg4j.dsi.unimi.it/">MG4J</a> to provide customisable word segmentation. - - <h3>Bit-level I/O</h3> - - <P>The standard Java API lacks bit-level I/O classes: to this purpose, we - provide {@link it.unimi.dsi.io.InputBitStream} and {@link - it.unimi.dsi.io.OutputBitStream}, which can wrap any standard Java - corresponding stream and make it work at the bit level; moreover, they - provide support for several useful formats (such as unary, binary, minimal - binary, γ, δ and Golomb encoding). - - <P>Bit input and output streams offer also efficient buffering and a way to - reposition the bit stream in case the underlying byte stream is a - file-based stream or a {@link it.unimi.dsi.fastutil.io.RepositionableStream}. - - <h2>Conventions</h2> - - <p><strong>All coding methods work on natural numbers</strong>. The - encoding of zero is very natural for some techniques, and much less natural - for others. To keep methods rationally organised, all methods are able to - encode any natural number. If, for instance, you want to write positive - numbers in unary encoding and you do not want to waste a bit, you have to - decrement them first (i.e., instead of <var>p</var> you must encode - <var>p</var>−1). - - </body> -</html> diff --git a/src/it/unimi/dsi/lang/EnumStringParser.java b/src/it/unimi/dsi/lang/EnumStringParser.java index 13da1a0477ed585f8fa7dfffa7bb661a9412decd..f5a14874ec979d655dad25504133b3f1fc3de5ae 100644 --- a/src/it/unimi/dsi/lang/EnumStringParser.java +++ b/src/it/unimi/dsi/lang/EnumStringParser.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2016-2020 Sebastiano Vigna + * Copyright (C) 2016-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.lang; diff --git a/src/it/unimi/dsi/lang/FlyweightPrototype.java b/src/it/unimi/dsi/lang/FlyweightPrototype.java index 72359ea9b0d7d9898da1b452e0e68b0c6884e94d..2079e0ed0155091695c328a8bbf457a94bd91cee 100644 --- a/src/it/unimi/dsi/lang/FlyweightPrototype.java +++ b/src/it/unimi/dsi/lang/FlyweightPrototype.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2006-2020 Sebastiano Vigna + * Copyright (C) 2006-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.lang; diff --git a/src/it/unimi/dsi/lang/FlyweightPrototypes.java b/src/it/unimi/dsi/lang/FlyweightPrototypes.java index a0e57dbfb10dbf438f7707e29b5cb158e9664f7a..6f167a64cd5750b904cfb93eb7be8837485c4ce7 100644 --- a/src/it/unimi/dsi/lang/FlyweightPrototypes.java +++ b/src/it/unimi/dsi/lang/FlyweightPrototypes.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2006-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2006-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.lang; diff --git a/src/it/unimi/dsi/lang/MutableString.java b/src/it/unimi/dsi/lang/MutableString.java index c7a07ef00366cb8937a4101a54c0ea4619f18350..b1db4fcab4a0e97b26c5abd0797999f983fc1b88 100644 --- a/src/it/unimi/dsi/lang/MutableString.java +++ b/src/it/unimi/dsi/lang/MutableString.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2002-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.lang; diff --git a/src/it/unimi/dsi/lang/ObjectParser.java b/src/it/unimi/dsi/lang/ObjectParser.java index b7b7e177436b5269e570c345f19881f506a33052..ee25d29ca8ce3c417dda2826e4370c78f45f7ab1 100644 --- a/src/it/unimi/dsi/lang/ObjectParser.java +++ b/src/it/unimi/dsi/lang/ObjectParser.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2006-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2006-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.lang; diff --git a/src/it/unimi/dsi/lang/package-info.java b/src/it/unimi/dsi/lang/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..ea3eaa59ec4d3b170ab4fb1ace1b345a5e96d0f7 --- /dev/null +++ b/src/it/unimi/dsi/lang/package-info.java @@ -0,0 +1,3 @@ +/** Basic classes */ + +package it.unimi.dsi.lang; diff --git a/src/it/unimi/dsi/lang/package.html b/src/it/unimi/dsi/lang/package.html deleted file mode 100644 index 5c53de5279f798fa8b929b90bb283647e5d7f53e..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/lang/package.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>Basic classes</title> - </head> -<body> - -<p>Basic classes. - -</body> -</html> diff --git a/src/it/unimi/dsi/logging/ProgressLogger.java b/src/it/unimi/dsi/logging/ProgressLogger.java index b3e07b6de3b4051b085997451ac7636965ee3a93..9fdf42b48bc315000ed991599a40d7c775322221 100644 --- a/src/it/unimi/dsi/logging/ProgressLogger.java +++ b/src/it/unimi/dsi/logging/ProgressLogger.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.logging; diff --git a/src/it/unimi/dsi/logging/package-info.java b/src/it/unimi/dsi/logging/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..2a1cb90f1817e6a0c35051e2cc0ef19fcc500d3f --- /dev/null +++ b/src/it/unimi/dsi/logging/package-info.java @@ -0,0 +1,3 @@ +/** Logging classes */ + +package it.unimi.dsi.logging; diff --git a/src/it/unimi/dsi/logging/package.html b/src/it/unimi/dsi/logging/package.html deleted file mode 100644 index 73363f13db372e43ddf02fc5ec6c8e01a67b27da..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/logging/package.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>Logging classes</title> - </head> -<body> - -<p>Logging classes. - -</body> -</html> diff --git a/src/it/unimi/dsi/package-info.java b/src/it/unimi/dsi/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..e4b6f62fa6d58f1e3a967cf1af7662f9a20a6105 --- /dev/null +++ b/src/it/unimi/dsi/package-info.java @@ -0,0 +1,3 @@ +/** General utilities */ + +package it.unimi.dsi; diff --git a/src/it/unimi/dsi/package.html b/src/it/unimi/dsi/package.html deleted file mode 100644 index 45776ea5bc95a9e25fa16b236f98c4ea82a3fe04..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/package.html +++ /dev/null @@ -1,7 +0,0 @@ -<html> -<head><title>General utilities</title></head> -<body> -<p>General utilities. - -</body> -</html> diff --git a/src/it/unimi/dsi/parser/Attribute.java b/src/it/unimi/dsi/parser/Attribute.java index f0c6f4995045a15842ea8bc780ea81d49b100ebb..8e20ca855e2000bbae096fb6ab68d4836ecbb15c 100644 --- a/src/it/unimi/dsi/parser/Attribute.java +++ b/src/it/unimi/dsi/parser/Attribute.java @@ -1,28 +1,32 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser; import it.unimi.dsi.lang.MutableString; -/** An SGML attribute. */ +/** + * An SGML attribute. + * + * @deprecated This class is obsolete and kept around for backward compatibility only. + */ +@Deprecated public final class Attribute { /** The name of this attribute. */ diff --git a/src/it/unimi/dsi/parser/BulletParser.java b/src/it/unimi/dsi/parser/BulletParser.java index 770ce7c90df4fdb3b8adc27205b1d70e749ba76f..cbb1dc8186ff76f2725fd2480ce421c8aefd7986 100644 --- a/src/it/unimi/dsi/parser/BulletParser.java +++ b/src/it/unimi/dsi/parser/BulletParser.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser; @@ -30,104 +29,107 @@ import it.unimi.dsi.parser.callback.Callback; import it.unimi.dsi.util.TextPattern; -/** A fast, lightweight, on-demand (X)HTML parser. +/** + * A fast, lightweight, on-demand (X)HTML parser. * - * <p>The bullet parser has been written with two specific goals in mind: - * web crawling and targeted data extraction from massive web data sets. - * To be usable in such environments, a parser must obey a number of - * restrictions: + * <p> + * The bullet parser has been written with two specific goals in mind: web crawling and targeted + * data extraction from massive web data sets. To be usable in such environments, a parser must obey + * a number of restrictions: * <ul> - * <li>it should avoid excessive object creation (which, for instance, - * forbids a significant usage of Java strings); - * <li>it should tolerate invalid syntax and recover reasonably; in fact, - * it should never throw exceptions; - * <li>it should perform actual parsing only on a settable feature subset: - * there is no reason to parse the attributes of a <code>P</code> - * element while searching for links; - * <li>it should parse HTML as a <em>regular language</em>, and leave context-free - * properties (e.g., stack maintenance and repair) to suitably designed callbacks. + * <li>it should avoid excessive object creation (which, for instance, forbids a significant usage + * of Java strings); + * <li>it should tolerate invalid syntax and recover reasonably; in fact, it should never throw + * exceptions; + * <li>it should perform actual parsing only on a settable feature subset: there is no reason to + * parse the attributes of a <code>P</code> element while searching for links; + * <li>it should parse HTML as a <em>regular language</em>, and leave context-free properties (e.g., + * stack maintenance and repair) to suitably designed callbacks. * </ul> * - * <p>Thus, in fact the bullet parser is not a parser. It is a bunch of - * spaghetti code that analyses a stream of characters pretending that - * it is an (X)HTML document. It has a very defensive attitude against - * the stream character it is parsing, but at the same time it is - * forgiving with all typical (X)HTML mistakes. + * <p> + * Thus, in fact the bullet parser is not a parser. It is a bunch of spaghetti code that analyses a + * stream of characters pretending that it is an (X)HTML document. It has a very defensive attitude + * against the stream character it is parsing, but at the same time it is forgiving with all typical + * (X)HTML mistakes. * - * <p>The bullet parser is officially StringFree™. - * <a href="http://dsiutils.di.unimi.it/docs/it/unimi/dsi/lang/MutableString.html"><code>MutableString</code>s</a> - * are used for internal processing, and Java strings are used only to return attribute - * values. All internal maps are {@linkplain it.unimi.dsi.fastutil.objects.Reference2ObjectMap reference-based maps} - * from <a href="http://fastutil.di.unimi.it/"><code>fastutil</code></a>, which - * helps to accelerate further the parsing process. + * <p> + * The bullet parser is officially StringFree™. <a href= + * "http://dsiutils.di.unimi.it/docs/it/unimi/dsi/lang/MutableString.html"><code>MutableString</code>s</a> + * are used for internal processing, and Java strings are used only to return attribute values. All + * internal maps are {@linkplain it.unimi.dsi.fastutil.objects.Reference2ObjectMap reference-based + * maps} from <a href="http://fastutil.di.unimi.it/"><code>fastutil</code></a>, which helps to + * accelerate further the parsing process. * * <h2>HTML data</h2> * - * <p>The bullet parser uses attributes and methods of {@link it.unimi.dsi.parser.HTMLFactory}, - * {@link it.unimi.dsi.parser.Element}, {@link it.unimi.dsi.parser.Attribute} - * and {@link it.unimi.dsi.parser.Entity}. - * Thus, for instance, whenever an element is to be passed around it is one - * of the shared objects contained in {@link it.unimi.dsi.parser.Element} - * (e.g., {@link it.unimi.dsi.parser.Element#BODY}). + * <p> + * The bullet parser uses attributes and methods of {@link it.unimi.dsi.parser.HTMLFactory}, + * {@link it.unimi.dsi.parser.Element}, {@link it.unimi.dsi.parser.Attribute} and + * {@link it.unimi.dsi.parser.Entity}. Thus, for instance, whenever an element is to be passed + * around it is one of the shared objects contained in {@link it.unimi.dsi.parser.Element} (e.g., + * {@link it.unimi.dsi.parser.Element#BODY}). * * <h2>Callbacks</h2> * - * <p>The result of the parsing process is the invocation of a callback. - * The {@linkplain it.unimi.dsi.parser.callback.Callback callback interface} - * of the bullet parser remembers closely SAX2, but it has some additional - * methods targeted at (X)HTML, such as {@link it.unimi.dsi.parser.callback.Callback#cdata(it.unimi.dsi.parser.Element,char[],int,int)}, + * <p> + * The result of the parsing process is the invocation of a callback. The + * {@linkplain it.unimi.dsi.parser.callback.Callback callback interface} of the bullet parser + * remembers closely SAX2, but it has some additional methods targeted at (X)HTML, such as + * {@link it.unimi.dsi.parser.callback.Callback#cdata(it.unimi.dsi.parser.Element,char[],int,int)}, * which returns characters found in a CDATA section (e.g., a stylesheet). * - * <p>Each callback must configure the parser, by requesting to perform - * the analysis and the callbacks it requires. A callback that wants to - * extract and tokenise text, for instance, will certainly require - * {@link #parseText(boolean) parseText(true)}, but not {@link #parseTags(boolean) parseTags(true)}. - * On the other hand, a callback wishing to extract links will require - * to {@linkplain #parseAttribute(Attribute) parse selectively} certain attribute types. + * <p> + * Each callback must configure the parser, by requesting to perform the analysis and the callbacks + * it requires. A callback that wants to extract and tokenise text, for instance, will certainly + * require {@link #parseText(boolean) parseText(true)}, but not {@link #parseTags(boolean) + * parseTags(true)}. On the other hand, a callback wishing to extract links will require to + * {@linkplain #parseAttribute(Attribute) parse selectively} certain attribute types. * - * <p>A more precise description follows. + * <p> + * A more precise description follows. * * <h2>Writing callbacks</h2> * - * <p>The first important issue is what has to be required to the parser. A newly - * created parser does not invoke any callback. It is up to every callback - * to add features so that it can do its job. Remember that since many - * callbacks can be {@linkplain it.unimi.dsi.parser.callback.ComposedCallbackBuilder composed}, - * you must always <em>add</em> features, never <em>remove</em> them, and moreover - * your callbacks must be ready to be invoked with features they did not - * request (e.g., attribute types added by another callback). + * <p> + * The first important issue is what has to be required to the parser. A newly created parser does + * not invoke any callback. It is up to every callback to add features so that it can do its job. + * Remember that since many callbacks can be + * {@linkplain it.unimi.dsi.parser.callback.ComposedCallbackBuilder composed}, you must always + * <em>add</em> features, never <em>remove</em> them, and moreover your callbacks must be ready to + * be invoked with features they did not request (e.g., attribute types added by another callback). * - * <p>The following parse features - * may be configured; most of them are just boolean features, a.k.a. flags: - * unless otherwise specified, by default all flags are set to false (e.g., by - * the default the parser will <em>not</em> parse tags): + * <p> + * The following parse features may be configured; most of them are just boolean features, a.k.a. + * flags: unless otherwise specified, by default all flags are set to false (e.g., by the default + * the parser will <em>not</em> parse tags): * <ul> - * <li><em>tags</em> ({@link #parseTags(boolean)} method): whether tags - * should be parsed; - * <li><em>attributes</em> ({@link #parseAttributes(boolean)} and - * {@link #parseAttribute(Attribute) methods)}: - * whether attributes should be parsed (of course, setting this flag is useless - * if you are not parsing tags); note that setting this flag will just - * activate the attribute parsing feature, but you must also - * {@linkplain #parseAttribute(Attribute) register} every attribute - * whose value you want to obtain. - * <li><em>text</em> ({@link #parseText(boolean)}method): whether text - * should be parsed; if this flag is set, the parser will call the - * {@link it.unimi.dsi.parser.callback.Callback#characters(char[], int, int, boolean)} - * method for every text chunk found. - * <li><em>CDATA sections</em> ({@link #parseCDATA(boolean)}method): whether CDATA - * sections (stylesheets & scripts) - * should be parsed; if this flag is set, the parser will call the - * {@link it.unimi.dsi.parser.callback.Callback#cdata(Element,char[],int,int)} - * method for every CDATA section found. + * <li><em>tags</em> ({@link #parseTags(boolean)} method): whether tags should be parsed; + * <li><em>attributes</em> ({@link #parseAttributes(boolean)} and {@link #parseAttribute(Attribute) + * methods)}: whether attributes should be parsed (of course, setting this flag is useless if you + * are not parsing tags); note that setting this flag will just activate the attribute parsing + * feature, but you must also {@linkplain #parseAttribute(Attribute) register} every attribute whose + * value you want to obtain. + * <li><em>text</em> ({@link #parseText(boolean)}method): whether text should be parsed; if this + * flag is set, the parser will call the + * {@link it.unimi.dsi.parser.callback.Callback#characters(char[], int, int, boolean)} method for + * every text chunk found. + * <li><em>CDATA sections</em> ({@link #parseCDATA(boolean)}method): whether CDATA sections + * (stylesheets & scripts) should be parsed; if this flag is set, the parser will call the + * {@link it.unimi.dsi.parser.callback.Callback#cdata(Element,char[],int,int)} method for every + * CDATA section found. * </ul> * * <h2>Invoking the parser</h2> * - * <p>After {@linkplain #setCallback(Callback) setting the parser callback}, - * you just call {@link #parse(char[], int, int)}. + * <p> + * After {@linkplain #setCallback(Callback) setting the parser callback}, you just call + * {@link #parse(char[], int, int)}. + * + * @deprecated This class is obsolete and kept around for backward compatibility only. */ +@Deprecated public class BulletParser { private static final boolean DEBUG = false; diff --git a/src/it/unimi/dsi/parser/Element.java b/src/it/unimi/dsi/parser/Element.java index 45c1637e2bcf53a8b1a872ee6ead8f106f00f64b..941a353fb29302fb4411950f6707a426a3de7259 100644 --- a/src/it/unimi/dsi/parser/Element.java +++ b/src/it/unimi/dsi/parser/Element.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser; @@ -25,7 +24,11 @@ import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet; import it.unimi.dsi.lang.MutableString; -/** An HTML element type. */ +/** + * An HTML element type. * @deprecated This class is obsolete and kept around for backward + * compatibility only. + */ +@Deprecated public final class Element { /** The name of the type of this element. */ diff --git a/src/it/unimi/dsi/parser/Entity.java b/src/it/unimi/dsi/parser/Entity.java index 62b254f05467c99d21c6ddc12d642c834c9c4797..bf3e127e1379d7949f03a97dcab717b086102414 100644 --- a/src/it/unimi/dsi/parser/Entity.java +++ b/src/it/unimi/dsi/parser/Entity.java @@ -1,29 +1,33 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser; import it.unimi.dsi.lang.MutableString; -/** An SGML character entity. */ +/** + * An SGML character entity. + * + * @deprecated This class is obsolete and kept around for backward compatibility only. + */ +@Deprecated public final class Entity { /** The name of this entity. */ diff --git a/src/it/unimi/dsi/parser/HTMLFactory.java b/src/it/unimi/dsi/parser/HTMLFactory.java index 45d63faa19dafb32ac04116849aad537b703e40a..807d365dab5ca90c4e7b0d6d9ec19da6a2b858ea 100644 --- a/src/it/unimi/dsi/parser/HTMLFactory.java +++ b/src/it/unimi/dsi/parser/HTMLFactory.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser; @@ -24,31 +23,36 @@ import it.unimi.dsi.fastutil.Hash; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.lang.MutableString; -/** A parsing factory for (X)HTML. +/** + * A parsing factory for (X)HTML. * - * <p><strong>Warning:</strong> for maximum flexibility, the methods of this factory - * do <em>not</em> perform case normalisation. If you are parsing HTML, you are invited - * to downcase your names before accessing {@link #getElement(MutableString)} - * and {@link #getAttribute(MutableString)}. + * <p> + * <strong>Warning:</strong> for maximum flexibility, the methods of this factory do <em>not</em> + * perform case normalisation. If you are parsing HTML, you are invited to downcase your names + * before accessing {@link #getElement(MutableString)} and {@link #getAttribute(MutableString)}. * - * <p>This class is a singleton, and its only instance is accessible using the public field + * <p> + * This class is a singleton, and its only instance is accessible using the public field * {@link #INSTANCE}. * - * <p>The relationship between this class and {@link Element}/{@link Attribute} is a bit - * twisted due to the need to accomodate two features: + * <p> + * The relationship between this class and {@link Element}/{@link Attribute} is a bit twisted due to + * the need to accomodate two features: * <ul> * <li>(X)HTML interned objects must be accessible directly (see, e.g., {@link Element#A}); * <li>(X)HTML interned objects must be put into suitable name-to-object maps. * </ul> * - * <p>To this purpose, this class exports packagewise some static factory methods that create {@link Element}s and - * {@link Attribute}s and register them locally. The static initialisation code in - * {@link Element} and {@link Attribute} creates elements such as {@link Element#A} using the abovementioned - * factory methods. + * <p> + * To this purpose, this class exports packagewise some static factory methods that create + * {@link Element}s and {@link Attribute}s and register them locally. The static initialisation code + * in {@link Element} and {@link Attribute} creates elements such as {@link Element#A} using the + * abovementioned factory methods. * - * <p>An alternative implementation could use reflection, but I don't see great advantages. + * @deprecated This class is obsolete and kept around for backward compatibility only. */ +@Deprecated public class HTMLFactory implements ParsingFactory { private HTMLFactory() {} diff --git a/src/it/unimi/dsi/parser/ParsingFactory.java b/src/it/unimi/dsi/parser/ParsingFactory.java index 990c4789a80c6ec72d9142d53ee0d9f58fef0354..3c9b2251d4a2e5fb7646e78a6b01d26c51d6d817 100644 --- a/src/it/unimi/dsi/parser/ParsingFactory.java +++ b/src/it/unimi/dsi/parser/ParsingFactory.java @@ -1,48 +1,53 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser; import it.unimi.dsi.lang.MutableString; -/** A set of coherent methods to turn element-type, attribute and entity names to unique interned instances. +/** + * A set of coherent methods to turn element-type, attribute and entity names to unique interned + * instances. * - * <p>The {@link it.unimi.dsi.parser.BulletParser} needs a way to turn - * a name (for an element type, attribute, or entity) into a corresponding object - * of type {@link it.unimi.dsi.parser.Element}, {@link it.unimi.dsi.parser.Attribute} - * or {@link it.unimi.dsi.parser.Entity}, respectively. The returned element must - * be an interned, unique representation. + * <p> + * The {@link it.unimi.dsi.parser.BulletParser} needs a way to turn a name (for an element type, + * attribute, or entity) into a corresponding object of type {@link it.unimi.dsi.parser.Element}, + * {@link it.unimi.dsi.parser.Attribute} or {@link it.unimi.dsi.parser.Entity}, respectively. The + * returned element must be an interned, unique representation. * - * <P>For instance, the {@linkplain it.unimi.dsi.parser.HTMLFactory standard factory for - * HTML} parsing has ready-made interned versions of all names in the (X)HTML specification, - * and returns them upon request, but other policies are possible. For instance, instances of - * {@link WellFormedXmlFactory} intern every seen name, without reference to a data type (except - * for entities, in which case the HTML set is used). + * <P> + * For instance, the {@linkplain it.unimi.dsi.parser.HTMLFactory standard factory for HTML} parsing + * has ready-made interned versions of all names in the (X)HTML specification, and returns them upon + * request, but other policies are possible. For instance, instances of {@link WellFormedXmlFactory} + * intern every seen name, without reference to a data type (except for entities, in which case the + * HTML set is used). * - * <P>The idea of factoring out the creation of interned counterparts of - * SGML/XML syntactical objects is due to Fabien Campagne. + * <P> + * The idea of factoring out the creation of interned counterparts of SGML/XML syntactical objects + * is due to Fabien Campagne. * * @author Sebastiano Vigna * @since 1.0.2 + * @deprecated This class is obsolete and kept around for backward compatibility only. */ +@Deprecated public interface ParsingFactory { /** Returns the {@link it.unimi.dsi.parser.Element} associated diff --git a/src/it/unimi/dsi/parser/WellFormedXmlFactory.java b/src/it/unimi/dsi/parser/WellFormedXmlFactory.java index 1e7715acab22de3274d9fd7d28404b594a09ac3a..c41183fa478b73f1c0bb2faa7f6c7c8e0b0f74b8 100644 --- a/src/it/unimi/dsi/parser/WellFormedXmlFactory.java +++ b/src/it/unimi/dsi/parser/WellFormedXmlFactory.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser; @@ -24,16 +23,19 @@ import it.unimi.dsi.fastutil.Hash; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.lang.MutableString; -/** A factory for well-formed XML documents. +/** + * A factory for well-formed XML documents. * - * <p>This factory assumes that every new name of an element type or of an - * attribute is new valid name. For entities, instead, resolution is - * deferred to {@link it.unimi.dsi.parser.HTMLFactory}. + * <p> + * This factory assumes that every new name of an element type or of an attribute is new valid name. + * For entities, instead, resolution is deferred to {@link it.unimi.dsi.parser.HTMLFactory}. * * @author Sebastiano Vigna * @since 1.0.2 + * @deprecated This class is obsolete and kept around for backward compatibility only. */ +@Deprecated public class WellFormedXmlFactory implements ParsingFactory { /** The load factor for all maps. */ private static final float ONE_HALF = .5f; diff --git a/src/it/unimi/dsi/parser/callback/Callback.java b/src/it/unimi/dsi/parser/callback/Callback.java index 32a2bd9ce61ab3c62d93fe369a0e12cfb3869991..0cf112eaee96059d44bf3ca2731fea82a30984e1 100644 --- a/src/it/unimi/dsi/parser/callback/Callback.java +++ b/src/it/unimi/dsi/parser/callback/Callback.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser.callback; @@ -27,17 +26,22 @@ import it.unimi.dsi.parser.Attribute; import it.unimi.dsi.parser.BulletParser; import it.unimi.dsi.parser.Element; -/** A callback for the {@linkplain it.unimi.dsi.parser.BulletParser bullet parser}. +/** + * A callback for the {@linkplain it.unimi.dsi.parser.BulletParser bullet parser}. * - * <P>This interface is very loosely inspired to the SAX2 interface. However, it - * strives to be simple, and to be StringFree™. + * <P> + * This interface is very loosely inspired to the SAX2 interface. However, it strives to be simple, + * and to be StringFree™. * - * <P>By contract, all implementations of this interface are bound to be <em>reusable</em>: - * by calling {@link #startDocument()}, a callback can be used again. - * It <strong>must</strong> be safe to call {@link #startDocument()} any number of times. + * <P> + * By contract, all implementations of this interface are bound to be <em>reusable</em>: by calling + * {@link #startDocument()}, a callback can be used again. It <strong>must</strong> be safe to call + * {@link #startDocument()} any number of times. * + * @deprecated This class is obsolete and kept around for backward compatibility only. */ +@Deprecated public interface Callback { /** A singleton empty callback array. */ diff --git a/src/it/unimi/dsi/parser/callback/ComposedCallbackBuilder.java b/src/it/unimi/dsi/parser/callback/ComposedCallbackBuilder.java index ca1fa126899ead1a1b5653f4abdde747bd4c9394..c1fd6efbf137c13b7bd0a64c7d4ea47d86e1998f 100644 --- a/src/it/unimi/dsi/parser/callback/ComposedCallbackBuilder.java +++ b/src/it/unimi/dsi/parser/callback/ComposedCallbackBuilder.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser.callback; @@ -28,14 +27,18 @@ import it.unimi.dsi.parser.Attribute; import it.unimi.dsi.parser.BulletParser; import it.unimi.dsi.parser.Element; -/** A builder for composed callbacks. +/** + * A builder for composed callbacks. + * + * <P> + * To compose a series of callbacks, you must first create an instance of this class, + * {@linkplain #add(Callback) add all required callbacks}, and finally {@linkplain #compose() get + * the composed callback}, which will invoke (in order) the callbacks. * - * <P>To compose a series of callbacks, you must first create an instance - * of this class, {@linkplain #add(Callback) add all required callbacks}, and - * finally {@linkplain #compose() get the composed callback}, which will invoke (in order) - * the callbacks. + * @deprecated This class is obsolete and kept around for backward compatibility only. */ +@Deprecated public class ComposedCallbackBuilder { /** A sequence of callbacks to be called int turn. */ diff --git a/src/it/unimi/dsi/parser/callback/DebugCallbackDecorator.java b/src/it/unimi/dsi/parser/callback/DebugCallbackDecorator.java index 222d1a300b7fa946c380daa9e3f996e5242e881a..181e61a00eac117c7735cb8320c6e44bd8dd7ab5 100644 --- a/src/it/unimi/dsi/parser/callback/DebugCallbackDecorator.java +++ b/src/it/unimi/dsi/parser/callback/DebugCallbackDecorator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser.callback; @@ -27,8 +26,12 @@ import it.unimi.dsi.parser.Attribute; import it.unimi.dsi.parser.BulletParser; import it.unimi.dsi.parser.Element; -/** A decorator that prints on standard error all calls to the underlying callback. +/** + * A decorator that prints on standard error all calls to the underlying callback. + * + * @deprecated This class is obsolete and kept around for backward compatibility only. */ +@Deprecated public class DebugCallbackDecorator implements Callback { /** The underlying callback. */ diff --git a/src/it/unimi/dsi/parser/callback/DefaultCallback.java b/src/it/unimi/dsi/parser/callback/DefaultCallback.java index 7693a2d7419c4170387b9d68bd548ef0c1eac5ee..f03df555d28e0bbba723a97ad937542ebce581a5 100644 --- a/src/it/unimi/dsi/parser/callback/DefaultCallback.java +++ b/src/it/unimi/dsi/parser/callback/DefaultCallback.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser.callback; @@ -30,11 +29,16 @@ import it.unimi.dsi.parser.Element; /** * A default, do-nothing-at-all callback. * - * <P>Callbacks can inherit from this class and forget about methods they are not interested in. + * <P> + * Callbacks can inherit from this class and forget about methods they are not interested in. * - * <P>This class has a protected constructor. If you need an instance of this class, use + * <P> + * This class has a protected constructor. If you need an instance of this class, use * {@link #getInstance()}. + * + * @deprecated This class is obsolete and kept around for backward compatibility only. */ +@Deprecated public class DefaultCallback implements Callback { private static final DefaultCallback SINGLETON = new DefaultCallback(); diff --git a/src/it/unimi/dsi/parser/callback/LinkExtractor.java b/src/it/unimi/dsi/parser/callback/LinkExtractor.java index a40cd792b7e2809c72cc7a881c1f23f93b380ddc..da3fa521169d6c81a7fdac96faed5f6224dc812c 100644 --- a/src/it/unimi/dsi/parser/callback/LinkExtractor.java +++ b/src/it/unimi/dsi/parser/callback/LinkExtractor.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser.callback; @@ -33,14 +32,16 @@ import it.unimi.dsi.util.TextPattern; /** * A callback extracting links. * - * <P>This callbacks extracts links existing in the web page. The - * links are then accessible in {@link #urls} (a set of {@link String}s). Note that - * we guarantee that the iteration order in the set is exactly - * the order in which links have been met (albeit copies appear - * just once). + * <P> + * This callbacks extracts links existing in the web page. The links are then accessible in + * {@link #urls} (a set of {@link String}s). Note that we guarantee that the iteration order in the + * set is exactly the order in which links have been met (albeit copies appear just once). + * + * @deprecated This class is obsolete and kept around for backward compatibility only. */ +@Deprecated public class LinkExtractor extends DefaultCallback { /** The pattern prefixing the URL in a <code>META </code> <code>HTTP-EQUIV </code> element of refresh type. */ private static final TextPattern URLEQUAL_PATTERN = new TextPattern("URL=", TextPattern.CASE_INSENSITIVE); diff --git a/src/it/unimi/dsi/parser/callback/TextExtractor.java b/src/it/unimi/dsi/parser/callback/TextExtractor.java index 6daac61df349458cb6b5add6ca5ebaec0bd85c87..598870627f2ade945c85391724c8140db8981b9e 100644 --- a/src/it/unimi/dsi/parser/callback/TextExtractor.java +++ b/src/it/unimi/dsi/parser/callback/TextExtractor.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser.callback; @@ -27,16 +26,21 @@ import it.unimi.dsi.parser.Attribute; import it.unimi.dsi.parser.BulletParser; import it.unimi.dsi.parser.Element; -/** A callback extracting text and titles. +/** + * A callback extracting text and titles. + * + * <P> + * This callbacks extracts all text in the page, and the title. The resulting text is available + * through {@link #text}, and the title through {@link #title}. * - * <P>This callbacks extracts all text in the page, and the title. - * The resulting - * text is available through {@link #text}, and the title through {@link #title}. + * <P> + * Note that {@link #text} and {@link #title} are never trimmed. * - * <P>Note that {@link #text} and {@link #title} are never trimmed. + * @deprecated This class is obsolete and kept around for backward compatibility only. */ +@Deprecated public class TextExtractor extends DefaultCallback { /** The text resulting from the parsing process. */ diff --git a/src/it/unimi/dsi/parser/callback/package-info.java b/src/it/unimi/dsi/parser/callback/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..b6b3a7cda13d7ac65883ea5abe307d7eb30db634 --- /dev/null +++ b/src/it/unimi/dsi/parser/callback/package-info.java @@ -0,0 +1,3 @@ +/** Callbacks for the {@link it.unimi.dsi.parser.BulletParser} */ + +package it.unimi.dsi.parser.callback; diff --git a/src/it/unimi/dsi/parser/callback/package.html b/src/it/unimi/dsi/parser/callback/package.html deleted file mode 100644 index 20bdf5383826043e759e8b82777d31443f8741e7..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/parser/callback/package.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>MG4J: Managing Gigabytes for Java</title> - </head> - - <body> - - Callbacks for the {@link it.unimi.dsi.parser.BulletParser}. - </body> -</html> diff --git a/src/it/unimi/dsi/parser/package-info.java b/src/it/unimi/dsi/parser/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..c5f297834436a9e0f061b4f444608e860dc342e2 --- /dev/null +++ b/src/it/unimi/dsi/parser/package-info.java @@ -0,0 +1,3 @@ +/** A fast, lightweight, on-demand (X)HTML parser */ + +package it.unimi.dsi.parser; diff --git a/src/it/unimi/dsi/parser/package.html b/src/it/unimi/dsi/parser/package.html deleted file mode 100644 index bf0381b6cb16ac4a866603be154cf9e0d6370d24..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/parser/package.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>MG4J: Managing Gigabytes for Java</title> - </head> - - <body> - - A fast, lightweight, on-demand (X)HTML parser. - </body> -</html> diff --git a/src/it/unimi/dsi/stat/Jackknife.java b/src/it/unimi/dsi/stat/Jackknife.java index 23993312c84cacc62657ae182b84fc4ab3fa8fc3..3685f25b174e65a8554763466ae432b3b2ae5e1b 100644 --- a/src/it/unimi/dsi/stat/Jackknife.java +++ b/src/it/unimi/dsi/stat/Jackknife.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2011-2020 Sebastiano Vigna + * Copyright (C) 2011-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.stat; diff --git a/src/it/unimi/dsi/stat/SummaryStats.java b/src/it/unimi/dsi/stat/SummaryStats.java index 6c432ed80aec1fc6f12d05cf664439dc47c6573a..abe72899a7d1fd1f595aa7b1a7e02b18ea2483f7 100644 --- a/src/it/unimi/dsi/stat/SummaryStats.java +++ b/src/it/unimi/dsi/stat/SummaryStats.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2011-2020 Sebastiano Vigna + * Copyright (C) 2011-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.stat; diff --git a/src/it/unimi/dsi/stat/Ziggurat.java b/src/it/unimi/dsi/stat/Ziggurat.java new file mode 100644 index 0000000000000000000000000000000000000000..db4f9db1a60dbca8862a9e5792e01b94dcaf59fb --- /dev/null +++ b/src/it/unimi/dsi/stat/Ziggurat.java @@ -0,0 +1,113 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.stat; + +import java.util.Random; + +import it.unimi.dsi.Util; +import it.unimi.dsi.bits.Fast; +import it.unimi.dsi.util.SplitMix64Random; + +public class Ziggurat { + private final Random random; + private static double[] x = new double[257]; + private static double[] x53 = new double[257]; + private static double[] y = new double[257]; + private static double[] h = new double[257]; + private static double[] h53 = new double[257]; + private static long[] threshold = new long[257]; + + static { + final double area = 3.949659822581572e-3; + + /* Warm-up. This is the point defining the bottom (tail) part. + * Note that 7.697117470131487 is the target for x[1] + * (from the original code). */ + x[0] = 8.69711747013488555703; + y[0] = 0; + h[0] = area / x[0]; // Never used, but necessary to compute the remaining data. + + for (int i = 1; i < 256; i++) { + y[i] = y[i - 1] + h[i - 1]; + x[i] = -Math.log(y[i]); + h[i] = area / x[i]; + } + + for (int i = 1; i < 256; i++) { + threshold[i] = Math.round((1L << 53) * x[i + 1] / x[i]); + // System.err.println(x[i] + " " + y[i] + " " + threshold[i - 1]); + } + + for (int i = 0; i < 256; i++) { + x53[i] = x[i] / (1L << 53); + h53[i] = h[i] / (1L << 53); + } + + y[256] = 1; // x[256] is 0. + } + + public Ziggurat() { + this.random = new SplitMix64Random(); + } + + public Ziggurat(final Random random) { + this.random = random; + } + + public double nextDouble() { + for(;;) { + final long r = random.nextLong(); + // We never extract 256 because it would fail anyway. + final int block = (int)(r & 0xFF); + // This is a discrete representation of a uniformly chosen random number in [0..x[block]). + final long discreteCandidate = r >>> 11; + if (discreteCandidate < threshold[block]) { + return discreteCandidate * x53[block]; + } + if (block == 0) { + // Slow but very rare. + return x[1] - Math.log(random.nextDouble()); + } + final double candidate = discreteCandidate * x53[block]; + if (y[block] + (random.nextLong() >>> 11) * h53[block] < Math.exp(-candidate)) return candidate; + } + } + + public static void main(final String arg[]) { + final Ziggurat ziggurat = new Ziggurat(new SplitMix64Random()); + final long time = - System.currentTimeMillis(); + final int n = Integer.parseInt(arg[0]); + double sum = 0; + final int numExp = 100; + final int exponentBits = 6; + final int maxExponent = 2; + final int minExponent = - (1 << exponentBits) + maxExponent + 1; + for(int t = numExp; t-- != 0;) { + int x = Integer.MAX_VALUE; + for(int k = n; k-- != 0;) { + x = Math.min(x, Math.max(Math.min(maxExponent, Fast.approximateLog2(ziggurat.nextDouble())), minExponent)); + } + sum += Fast.pow2(x); + } + + System.err.println(1000000.0 * (time + System.currentTimeMillis()) / (n * numExp) + " ns/gen"); + System.out.println(numExp / sum + " (" + Util.format(100 * (numExp / sum - n) / n) + "%)"); + } +} diff --git a/src/it/unimi/dsi/stat/package-info.java b/src/it/unimi/dsi/stat/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..59cc2e13117e51a5cf3a75494f1b513da8c2b454 --- /dev/null +++ b/src/it/unimi/dsi/stat/package-info.java @@ -0,0 +1,3 @@ +/** Statistics classes */ + +package it.unimi.dsi.stat; diff --git a/src/it/unimi/dsi/stat/package.html b/src/it/unimi/dsi/stat/package.html deleted file mode 100644 index d8fabd4e8644861447b9bf3edc92b5066e3409fe..0000000000000000000000000000000000000000 --- a/src/it/unimi/dsi/stat/package.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <title>Statistics classes</title> - </head> -<body> - -<p>Statistics classes. - -</body> -</html> diff --git a/src/it/unimi/dsi/test/GeneratePrecomputedCodes.java b/src/it/unimi/dsi/test/GeneratePrecomputedCodes.java new file mode 100644 index 0000000000000000000000000000000000000000..25f2dc789f8197a5a9bb960520c9bd3ea71d8894 --- /dev/null +++ b/src/it/unimi/dsi/test/GeneratePrecomputedCodes.java @@ -0,0 +1,212 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.io.EOFException; +import java.io.IOException; + +import it.unimi.dsi.fastutil.io.BinIO; +import it.unimi.dsi.io.InputBitStream; +import it.unimi.dsi.io.OutputBitStream; + +public final class GeneratePrecomputedCodes { + + private static OutputBitStream outputBitStream; + + private GeneratePrecomputedCodes() {} + + private static int readUnary(final InputBitStream ibs) throws IOException { + int x = 0; + while(ibs.readBit() == 0) x++; + return x; + } + + public static void main(final String[] arg) throws IOException { + + final int length = Integer.parseInt(arg[0]); + final int size = arg.length < 2 ? 1 << length : Integer.parseInt(arg[1]); + + final byte[] a = new byte[2]; + final InputBitStream inputBitStream = new InputBitStream(a); + outputBitStream = new OutputBitStream(a); + int v, l; + + //System.out.println("\tprivate final static int[] GAMMA = {"); + + final int[] precomp = new int[size]; + + int p1, p2; + + for(int i = 0; i < size; i++) { + outputBitStream.flush(); + outputBitStream.position(0); + outputBitStream.writeInt(i, 16); + outputBitStream.flush(); + + inputBitStream.flush(); + inputBitStream.position(16 - length); + inputBitStream.readBits(0); + v = l = 0; + try { + v = readUnary(inputBitStream); + l = (int)inputBitStream.readBits(); + if (v > 0xFFF || l > 0x10) throw new IllegalStateException("v: " + v + " l:" + l); + } + catch(final EOFException e){} + catch(final IllegalArgumentException e){} // excessive length + precomp[i] = l << 16 | v; + //if (i % sqrtLength == 0) System.out.print("\t\t"); + //String s = v == 0 && l == 0 ? "0" : l + " << 16 | " + v; + //if (l > 7) s = "(short)(" + s + ")"; + //System.out.print(s + ((i + 1) % sqrtLength == 0 ? ",\n" : ", ")); + } + + BinIO.storeInts(precomp, "unary.in." + length); + + //System.out.println("\t};\n\n"); + + //System.out.println("\tprivate final static int[] DELTA = {"); + + + for(int i = 0; i < size; i++) { + outputBitStream.flush(); + outputBitStream.position(0); + outputBitStream.writeInt(i, 16); + outputBitStream.flush(); + + inputBitStream.flush(); + inputBitStream.position(16 - length); + inputBitStream.readBits(0); + v = l = 0; + try { + p1 = readUnary(inputBitStream); + v = (1 << p1 | inputBitStream.readInt(p1)) - 1; + l = (int)inputBitStream.readBits(); + if (v > 0xFFF || l > 0x10) throw new IllegalStateException("v: " + v + " l:" + l); + } + catch(final EOFException e){} + catch(final IllegalArgumentException e){} // excessive length + precomp[i] = l << 16 | v; + //if (i % sqrtLength == 0) System.out.print("\t\t"); + //String s = v == 0 && l == 0 ? "0" : l + " << 16 | " + v; + //if (l > 7) s = "(short)(" + s + ")"; + //System.out.print(s + ((i + 1) % sqrtLength == 0 ? ",\n" : ", ")); + } + + BinIO.storeInts(precomp, "gamma.in." + length); + + //System.out.println("\t};\n\n"); + + //System.out.println("\tprivate final static int[] DELTA = {"); + + for(int i = 0; i < size; i++) { + outputBitStream.flush(); + outputBitStream.position(0); + outputBitStream.writeInt(i, 16); + outputBitStream.flush(); + + inputBitStream.flush(); + inputBitStream.position(16 - length); + inputBitStream.readBits(0); + v = l = 0; + try { + p1 = readUnary(inputBitStream); + p2 = (1 << p1 | inputBitStream.readInt(p1)) - 1; + v = (1 << p2 | inputBitStream.readInt(p2)) - 1; + l = (int)inputBitStream.readBits(); + if (v > 0xFFF || l > 0x10) throw new IllegalStateException("v: " + v + " l:" + l); + } + catch(final EOFException e){} + catch(final IllegalArgumentException e){} // excessive length + + precomp[i] = l << 16 | v; + //if (i % sqrtLength == 0) System.out.print("\t\t"); + //String s = v == 0 && l == 0 ? "0" : l + " << 16 | " + v; + //if (l > 7) s = "(short)(" + s + ")"; + //System.out.print(s + ((i + 1) % sqrtLength == 0 ? ",\n" : ", ")); + } + + //System.out.println("\t};\n\n"); + + BinIO.storeInts(precomp, "delta.in." + length); + + for(int i = 0; i < size; i++) { + outputBitStream.flush(); + outputBitStream.position(0); + outputBitStream.writeInt(i, 16); + outputBitStream.flush(); + + inputBitStream.flush(); + inputBitStream.position(16 - length); + inputBitStream.readBits(0); + v = l = 0; + try { + p1 = readUnary(inputBitStream) - 1; + v = p1 == -1 ? 0 : (1 << p1 | inputBitStream.readInt(p1)); + l = (int)inputBitStream.readBits(); + if (v > 0xFFF || l > 0x10) throw new IllegalStateException("v: " + v + " l:" + l); + } + catch(final EOFException e){} + catch(final IllegalArgumentException e){} // excessive length + precomp[i] = l << 16 | v; + //if (i % sqrtLength == 0) System.out.print("\t\t"); + //String s = v == 0 && l == 0 ? "0" : l + " << 16 | " + v; + //if (l > 7) s = "(short)(" + s + ")"; + //System.out.print(s + ((i + 1) % sqrtLength == 0 ? ",\n" : ", ")); + } + + BinIO.storeInts(precomp, "shiftedgamma.in." + length); + + //System.out.println("\tprivate final static int[] ZETA_3 = {"); + + for(int i = 0; i < size; i++) { + outputBitStream.flush(); + outputBitStream.position(0); + outputBitStream.writeInt(i, 16); + outputBitStream.flush(); + + inputBitStream.flush(); + inputBitStream.position(16 - length); + inputBitStream.readBits(0); + v = l = 0; + try { + final int h = readUnary(inputBitStream); + final int left = 1 << h * 3; + final int m = inputBitStream.readInt(h * 3 + 3 - 1); + if (m < left) v = m + left - 1; + else v = (m << 1) + inputBitStream.readBit() - 1; + l = (int)inputBitStream.readBits(); + if (v > 0xFFF || l > 0x10) throw new IllegalStateException("v: " + v + " l:" + l); + } + catch(final EOFException e){} + catch(final IllegalArgumentException e){} // excessive length + + precomp[i] = l << 16 | v; + //if (i % sqrtLength == 0) System.out.print("\t\t"); + //String s = v == 0 && l == 0 ? "0" : l + " << 16 | " + v; + //if (l > 7) s = "(short)(" + s + ")"; + //System.out.print(s + ((i + 1) % sqrtLength == 0 ? ",\n" : ", ")); + } + + //System.out.println("\t};\n\n"); + BinIO.storeInts(precomp, "zeta3.in." + length); + + } +} diff --git a/src/it/unimi/dsi/test/GeneratePrecomputedOutputCodes.java b/src/it/unimi/dsi/test/GeneratePrecomputedOutputCodes.java new file mode 100644 index 0000000000000000000000000000000000000000..b860ecd3b00203ebbb84484fbb28e302ef009b97 --- /dev/null +++ b/src/it/unimi/dsi/test/GeneratePrecomputedOutputCodes.java @@ -0,0 +1,147 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.io.IOException; +import java.util.Arrays; + +import it.unimi.dsi.bits.Fast; +import it.unimi.dsi.fastutil.io.BinIO; +import it.unimi.dsi.io.InputBitStream; +import it.unimi.dsi.io.OutputBitStream; + +public final class GeneratePrecomputedOutputCodes { + + private GeneratePrecomputedOutputCodes() {} + + public static int writeUnary(final int x, final OutputBitStream obs) throws IOException { + for(int i = 0; i < x; i++) obs.writeBit(0); + obs.writeBit(1); + return x + 1; + } + + public static int writeGamma(int x, final OutputBitStream obs) throws IOException { + final int msb = Fast.mostSignificantBit(++x); + final int l = writeUnary(msb, obs); + return l + (msb != 0 ? obs.writeInt(x, msb) : 0); + } + + public static int writeDelta(int x, final OutputBitStream obs) throws IOException { + final int msb = Fast.mostSignificantBit(++x); + final int l = writeGamma(msb, obs); + return l + (msb != 0 ? obs.writeInt(x, msb) : 0); + } + + public static int writeZeta(int x, final int k, final OutputBitStream obs) throws IOException { + final int msb = Fast.mostSignificantBit(++x); + final int h = msb / k; + final int l = writeUnary(h, obs); + final int left = 1 << h * k; + return l + (x - left < left + ? obs.writeInt(x - left, h * k + k - 1) + : obs.writeInt(x, h * k + k)); + } + + public static int writeShiftedGamma(final int x, final OutputBitStream obs) throws IOException { + final int msb = Fast.mostSignificantBit(x); + final int l = writeUnary(msb + 1, obs); + return l + (msb != -1 ? obs.writeInt(x, msb) : 0); + } + + + public static void main(final String[] arg) throws IOException { + + final int length = Integer.parseInt(arg[0]); + final int size = 1 << length; + + final byte[] a = new byte[4]; + @SuppressWarnings("resource") + final InputBitStream inputBitStream = new InputBitStream(a); + final OutputBitStream outputBitStream= new OutputBitStream(a); + int l, v; + + final int[] precomp = new int[size]; + + for(int i = 0; i < size; i++) { + Arrays.fill(a, (byte)0); + outputBitStream.flush(); + outputBitStream.position(0); + l = writeGamma(i, outputBitStream); + outputBitStream.flush(); + inputBitStream.flush(); + inputBitStream.position(0); + v = inputBitStream.readInt(l); + if (l > 26) throw new IllegalArgumentException(); + if (Fast.mostSignificantBit(l) > 5) throw new IllegalArgumentException(); + precomp[i] = l << 26 | v; + } + + BinIO.storeInts(precomp, "gamma.out." + length); + + for(int i = 0; i < size; i++) { + Arrays.fill(a, (byte)0); + outputBitStream.flush(); + outputBitStream.position(0); + l = writeDelta(i, outputBitStream); + outputBitStream.flush(); + inputBitStream.flush(); + inputBitStream.position(0); + v = inputBitStream.readInt(l); + if (l > 26) throw new IllegalArgumentException(); + if (Fast.mostSignificantBit(l) > 5) throw new IllegalArgumentException(); + precomp[i] = l << 26 | v; + } + + BinIO.storeInts(precomp, "delta.out." + length); + + for(int i = 0; i < size; i++) { + Arrays.fill(a, (byte)0); + outputBitStream.flush(); + outputBitStream.position(0); + l = writeZeta(i, 3, outputBitStream); + outputBitStream.flush(); + inputBitStream.flush(); + inputBitStream.position(0); + v = inputBitStream.readInt(l); + if (l > 26) throw new IllegalArgumentException(); + if (Fast.mostSignificantBit(l) > 5) throw new IllegalArgumentException(); + precomp[i] = l << 26 | v; + } + + BinIO.storeInts(precomp, "zeta3.out." + length); + + for(int i = 0; i < size; i++) { + Arrays.fill(a, (byte)0); + outputBitStream.flush(); + outputBitStream.position(0); + l = writeShiftedGamma(i, outputBitStream); + outputBitStream.flush(); + inputBitStream.flush(); + inputBitStream.position(0); + v = inputBitStream.readInt(l); + if (l > 26) throw new IllegalArgumentException(); + if (Fast.mostSignificantBit(l) > 5) throw new IllegalArgumentException(); + precomp[i] = l << 26 | v; + } + + BinIO.storeInts(precomp, "shiftedgamma.out." + length); + + } +} diff --git a/src/it/unimi/dsi/test/InputBitStreamSpeedTest.java b/src/it/unimi/dsi/test/InputBitStreamSpeedTest.java new file mode 100644 index 0000000000000000000000000000000000000000..dc1a2a84d2f007e29efcf2ba9d1240ff6b20176e --- /dev/null +++ b/src/it/unimi/dsi/test/InputBitStreamSpeedTest.java @@ -0,0 +1,99 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +import it.unimi.dsi.io.InputBitStream; +import it.unimi.dsi.io.OutputBitStream; +import it.unimi.dsi.logging.ProgressLogger; + +public class InputBitStreamSpeedTest { + + private InputBitStreamSpeedTest() {} + + public static void main(final String[] arg) throws IOException { + int k; + final int n = Integer.parseInt(arg[0]); + int i; + final java.util.Random r = new java.util.Random(); + final ProgressLogger pl = new ProgressLogger(); + final int data1[] = new int[1000000]; + final int data2[] = new int[1000000]; + i = 1000000; + while(i-- != 0) data2[i] = (data1[i] = r.nextInt(100)) + 1; + + + k = 10; + while(k-- != 0) { + + i = n; + pl.start(); + final OutputBitStream bos = new OutputBitStream(new FileOutputStream("test "), 16*1024); + while(i-- != 0) bos.writeGamma(data1[i % 1000000]); + bos.close(); + pl.done(); + + System.err.println("Written " + n + " integers on OutputBitStream in " + pl.millis() + " ms (" + (1000.0 * n) / pl.millis() + " int/s)"); + + + pl.start(); + final InputBitStream bis = new InputBitStream(new FileInputStream("test "), 16*1024); + i = n; + while(i-- != 0) bis.readGamma(); + bis.close(); + pl.stop(); + + System.err.println("Read " + n + " integers from InputBitStream in " + pl.millis() + " ms (" + (1000.0 * n) / pl.millis() + " int/s)"); + + } + +/* k = 10; + while(k-- != 0) { + + i = n; + pl.reset(); + pl.start(); + BitOutputStream bos = new BitOutputStream(new FileOutputStream("test ")); + while(i-- != 0) bos.writeGamma(data2[i % 1000000]); + bos.close(); + pl.stop(); + + System.err.println("Written " + n + " integers on BitOutputStream in " + pl.millis() + " ms (" + (1000.0 * n) / pl.millis() + " int/s)"); + + + pl.reset(); + pl.start(); + BitInputStream bis = new BitInputStream(new FileInputStream("test ")); + i = n; + while(i-- != 0) bis.readGamma(); + bis.close(); + pl.stop(); + + System.err.println("Read " + n + " integers from BitInputStream in " + pl.millis() + " ms (" + (1000.0 * n) / pl.millis() + " int/s)"); + + }*/ + } + + +} + diff --git a/src/it/unimi/dsi/test/LeastSignificantBitSpeedTest.java b/src/it/unimi/dsi/test/LeastSignificantBitSpeedTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0a1685dfcfdbe884b38ca76ba636d5ddfed1ce43 --- /dev/null +++ b/src/it/unimi/dsi/test/LeastSignificantBitSpeedTest.java @@ -0,0 +1,128 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import it.unimi.dsi.util.XoRoShiRo128PlusRandomGenerator; + +public class LeastSignificantBitSpeedTest { + + /** + * The set of least-significant bits for a given <code>byte</code>. <code>-1</code> + * is used if no bits are set (so as to not be confused with "index of zero" + * meaning that the least significant bit is the 0th (1st) bit). + * + * @see #leastSignificantBit(long) + */ + private static final int[] LEAST_SIGNIFICANT_BIT = { + -1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, + 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 + }; + + /** + * Computes the least-significant bit of the specified <code>long</code> + * that is set to <code>1</code>. Zero-indexed. + * + * @param value the <code>long</code> whose least-significant bit is desired. + * @return the least-significant bit of the specified <code>long</code>. + * <code>-1</code> is returned if there are no bits set. + */ + // REF: http://stackoverflow.com/questions/757059/position-of-least-significant-bit-that-is-set + // REF: http://www-graphics.stanford.edu/~seander/bithacks.html + public static int leastSignificantBit(final long value) { + if(value == 0L) return -1/*by contract*/; + if((value & 0xFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)((value >>> 0) & 0xFF)] + 0; + if((value & 0xFFFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)((value >>> 8) & 0xFF)] + 8; + if((value & 0xFFFFFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)((value >>> 16) & 0xFF)] + 16; + if((value & 0xFFFFFFFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)((value >>> 24) & 0xFF)] + 24; + if((value & 0xFFFFFFFFFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)((value >>> 32) & 0xFF)] + 32; + if((value & 0xFFFFFFFFFFFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)((value >>> 40) & 0xFF)] + 40; + if((value & 0xFFFFFFFFFFFFFFL) != 0) return LEAST_SIGNIFICANT_BIT[(int)((value >>> 48) & 0xFF)] + 48; + return LEAST_SIGNIFICANT_BIT[(int)((value >>> 56) & 0xFFL)] + 56; + } + + public static int javaLsb(final long value) { + return value == 0 ? -1 : Long.numberOfTrailingZeros(value); + } + + private final static byte[] LSB_TABLE = { + 0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6 + }; + + private static int deBrujin(final long x) { + return LSB_TABLE[(int)(((x & -x) * 0x03f79d71b4ca8b09L) >>> 58)]; + } + + + public static void main(final String a[]) { + final int n = Integer.parseInt(a[0]); + + final XoRoShiRo128PlusRandomGenerator r = new XoRoShiRo128PlusRandomGenerator(1); + long start, elapsed; + + int x = 42; + + final long value[] = new long[n]; + for(int i = n; i-- != 0;) value[i] = r.nextLong(); + + for(int k = 10; k-- !=0;) { + System.out.print("Java: "); + + start = System.nanoTime(); + for(int i = n; i-- != 0;) x ^= javaLsb(value[i]); + elapsed = System.nanoTime() - start; + + System.out.println("elapsed " + elapsed + ", " + (double)elapsed / n + " ns/call"); + + System.out.print("Test-based: "); + + start = System.nanoTime(); + for(int i = n; i-- != 0;) x ^= leastSignificantBit(value[i]); + elapsed = System.nanoTime() - start; + + System.out.println("elapsed " + elapsed + ", " + (double)elapsed / n + " ns/call"); + + System.out.print("De Brujin: "); + + start = System.nanoTime(); + for(int i = n; i-- != 0;) x ^= deBrujin(value[i]); + elapsed = System.nanoTime() - start; + + System.out.println("elapsed " + elapsed + ", " + (double)elapsed / n + " ns/call"); + + } + + if (x == 0) System.out.println(0); + + } +} diff --git a/src/it/unimi/dsi/test/MutableStringLengthSpeedTest.java b/src/it/unimi/dsi/test/MutableStringLengthSpeedTest.java new file mode 100644 index 0000000000000000000000000000000000000000..752a1daafc00ece3666e3c960f234ed5d0f948ad --- /dev/null +++ b/src/it/unimi/dsi/test/MutableStringLengthSpeedTest.java @@ -0,0 +1,98 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import it.unimi.dsi.lang.MutableString; + +public class MutableStringLengthSpeedTest { + + private MutableStringLengthSpeedTest() {} + + public static void main(final String[] arg) { + + long i, n; + + n = Long.parseLong(arg[0]); + + final MutableString s = new MutableString("foobar0"); + final MutableString t = new MutableString("foobar1"); + final String u = new String("foobar2"); + final StringBuffer v = new StringBuffer("foobar3"); + final StringBuilder w = new StringBuilder("foobar4"); + + int k = 10; + int x = 0; + + while (k-- != 0) { + long start; + + System.out.println(); + + start = -System.nanoTime(); + + i = n; + while (i-- != 0) x ^= u.length(); + + start += System.nanoTime(); + + System.out.println("Called length() " + n + " times on a string in " + start + " ns (" + start / (double)n + " ns/call)"); + + + start = -System.nanoTime(); + + i = n; + while (i-- != 0) x ^= t.length(); + + start += System.nanoTime(); + + System.out.println("Called length() " + n + " times on a compact string in " + start + " ns (" + start / (double)n + " ns/call)"); + + start = -System.nanoTime(); + + i = n; + s.loose(); + while (i-- != 0) x ^= s.length(); + + start += System.nanoTime(); + + System.out.println("Called length() " + n + " times on a loose string in " + start + " ns (" + start / (double)n + " ns/call)"); + + start = -System.nanoTime(); + + i = n; + while (i-- != 0) x ^= v.length(); + + start += System.nanoTime(); + + System.out.println("Called length() " + n + " times on a string buffer in " + start + " ns (" + start / (double)n + " ns/call)"); + + start = -System.nanoTime(); + + i = n; + while (i-- != 0) x ^= w.length(); + + start += System.nanoTime(); + if (x == 0) System.out.println(); + System.out.println("Called length() " + n + " times on a string builder in " + start + " ns (" + start / (double)n + " ns/call)"); + } + + } + +} diff --git a/src/it/unimi/dsi/test/MutableStringRegressionTest.java b/src/it/unimi/dsi/test/MutableStringRegressionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7fbad91c7e4194901984569fb1606fc7bf48d3c8 --- /dev/null +++ b/src/it/unimi/dsi/test/MutableStringRegressionTest.java @@ -0,0 +1,1483 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + + + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; + +import it.unimi.dsi.fastutil.chars.Char2CharMap; +import it.unimi.dsi.fastutil.chars.Char2CharOpenHashMap; +import it.unimi.dsi.fastutil.chars.CharArrayList; +import it.unimi.dsi.fastutil.chars.CharOpenHashSet; +import it.unimi.dsi.fastutil.chars.CharSet; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import it.unimi.dsi.fastutil.objects.ObjectSets; +import it.unimi.dsi.lang.MutableString; +import it.unimi.dsi.util.TextPattern; +import it.unimi.dsi.util.XoRoShiRo128PlusRandomGenerator; + + +/** + * A class for torture-testing {@link MutableString}s. + * + * @author Paolo Boldi + * @author Sebastiano Vigna + * @since 0.3 + * + */ + +@SuppressWarnings({ "unchecked", "rawtypes" }) +public class MutableStringRegressionTest { + + private MutableStringRegressionTest() {} + + /** Maximum integer to be generated. */ + private static final int MAXINT = 100; + /** Maximum short to be generated. */ + private static final int MAXSHORT = 10000; + /** Minimum/maximum character to be generated. */ + private static final int MINCHAR = 'A', MAXCHAR = 'Z'; + /** About one each <code>SPACE_FREQ</code> characters will be spaces. */ + private static final int SPACE_FREQ = 8; + /** Maximum length of a char array / String etc. */ + private static final int MAXLENGTH = 100; + + /** Methods declared by StringBuffer. */ + private static Method sbMethod[]; + /** Methods declared by MutableString. */ + private static Method msMethod[]; + /** How many times method <code>sbMethod[i]</code> (<code>msMethod[i]</code>) has been tested. */ + private static int sbTimes[], msTimes[]; + /** How many times method <code>sbMethod[i]</code> (<code>msMethod[i]</code>) has thrown an exception. */ + private static int sbExc[], msExc[]; + /** The Random object used by the test. */ + private static XoRoShiRo128PlusRandomGenerator rand; + + /** A map that sends Classes to Sets of alternative Classes... */ + private static Map<Class,Set<Class>> alternativeType; + + /** Index of the lastly generated method in <code>sbMethod</code> (<code>msMethod</code>). */ + private static int sbIdx, msIdx; + /** An array of alternative types to be used for {@link StringBuffer}. Usually, this is {@code null}. */ + private static Class alternativeParameterType[]; + + static { + sbMethod = StringBuffer.class.getDeclaredMethods(); + msMethod = MutableString.class.getDeclaredMethods(); + + sbTimes = new int[sbMethod.length]; + msTimes = new int[msMethod.length]; + sbExc = new int[sbMethod.length]; + msExc = new int[msMethod.length]; + + alternativeType = new HashMap<>(); + alternativeType.put(MutableString.class, new ObjectOpenHashSet<>(new Class[] { String.class, StringBuffer.class })); + alternativeType.put(String.class, ObjectSets.singleton((Class)StringBuffer.class)); + alternativeType.put(StringBuffer.class, ObjectSets.singleton((Class)String.class)); + alternativeType.put(CharSequence.class, ObjectSets.singleton((Class)String.class)); + alternativeType.put(char.class, ObjectSets.singleton((Class)String.class)); + + alternativeParameterType = null; + } + + private static String a2s(final Object o[]) { + String res = "["; + for (int i = 0; i < o.length; i++) res = res + (i>0? "," : "") + (o[i] instanceof char[]? (CharArrayList.wrap((char []) o[i])).toString() : String.valueOf(o[i])); + return res + "]"; + } + + private static MutableString s2i(final MutableString s) { + final MutableString res = new MutableString().append("["); + for (int i = 0; i < s.length(); i++) res.append(i != 0 ? ", " : "").append((int)s.charAt(i)); + return res.append("]"); + } + + /** An array of {@link Set} is given. This method considers all possible arrays where <code>i</code>-th entry is + an element of the <code>i</code>-th Set, and produces an {@link Iterator} returning such arrays in a fixed + order, starting from a random position. */ + private static Iterator possibleComb(final Set o[]) { + final int n = o.length; + int c = 1; + for (int i = 0; i < n; i++) c *= o[i].size(); + final int m = c; + + return new Iterator() { + int emitted = 0, nextEmit = rand.nextInt(m); + @Override + public boolean hasNext() { return emitted < m; } + @Override + public void remove() { throw new UnsupportedOperationException(); } + @Override + public Object next() { + if (emitted >= m) throw new NoSuchElementException(); + final Object res[] = new Object[n]; + int residual = nextEmit; + for (int i = 0; i < n; i++) { + final int j = residual % o[i].size(); + residual /= o[i].size(); + final Object a[] = o[i].toArray(); + res[i] = a[j]; + } + emitted++; + nextEmit = (nextEmit + 1) % m; + return res; + } + }; + } + + /** Extract a method at random that belongs to both classes. Sets <code>msIdx</code>, <code>sbIdx</code>. */ + public static Method randomMethod() { + Method msm, sbm; + alternativeParameterType = null; + do { + // Generate a method at random from MutableString + msm = msMethod[rand.nextInt(msMethod.length)]; + if (! Modifier.isPublic(msm.getModifiers())) continue; + for (msIdx = 0; msIdx < msMethod.length; msIdx++) if (msMethod[msIdx].equals(msm)) break; + if (msIdx == msMethod.length) { + throw new IllegalStateException("I was looking for " + msm); + } + // Test that the method belongs to both; if so, return it + try { + sbm = StringBuffer.class.getDeclaredMethod(msm.getName(), msm.getParameterTypes()); + if (! Modifier.isPublic(sbm.getModifiers())) continue; + for (sbIdx = 0; sbIdx < sbMethod.length; sbIdx++) if (sbMethod[sbIdx].equals(sbm)) break; + if (sbIdx == sbMethod.length) { + throw new IllegalStateException("I was looking for " + sbm); + } + return msm; + } catch (final NoSuchMethodException e) { + // The method was not found; try to change its parameters in every possible way and see whether + // it can be matched anyway, modulo a parameter change + final Class type[] = msm.getParameterTypes(); + final Set<Class> alternat[] = new Set[type.length]; + for (int i = 0; i < type.length; i++) { + alternat[i] = new HashSet<>(); alternat[i].add(type[i]); + if (alternativeType.containsKey(type[i])) + alternat[i].addAll(alternativeType.get(type[i])); + } + final Iterator it = possibleComb(alternat); + while (it.hasNext()) { + final Object o[] = (Object [])it.next(); + final Class altPar[] = new Class[o.length]; + System.arraycopy(o, 0, altPar, 0, o.length); + try { + sbm = StringBuffer.class.getDeclaredMethod(msm.getName(), altPar); + if (! Modifier.isPublic(sbm.getModifiers())) continue; + } catch (final NoSuchMethodException e1) { continue; } + // A method was found! Look for its index... + for (sbIdx = 0; sbIdx < sbMethod.length; sbIdx++) if (sbMethod[sbIdx].equals(sbm)) break; + if (sbIdx == sbMethod.length) { + throw new IllegalStateException("I was looking for " + sbm); + } + // Now copy the altPar + alternativeParameterType = new Class[altPar.length]; + System.arraycopy(altPar, 0, alternativeParameterType, 0, altPar.length); + //System.err.println("Using " + sbm + " as an alternative to " + msm); + return msm; + } + } + } while (true); + } + + /** Generate and return an array of Objects at random suitable for method m. */ + public static Object[] params(final Method m) { + final Class types[] = m.getParameterTypes(); + final Object res[] = new Object[types.length]; + for (int i = 0; i < types.length; i++) { + if (types[i].getName().equals("byte")) res[i] = Byte.valueOf((byte) rand.nextInt(256)); + else if (types[i].getName().equals("char")) res[i] = Character.valueOf((char) (MINCHAR + rand.nextInt(MAXCHAR-MINCHAR+1))); + else if (types[i].getName().equals("double")) res[i] = Double.valueOf(rand.nextDouble()); + else if (types[i].getName().equals("float")) res[i] = Float.valueOf(rand.nextFloat()); + else if (types[i].getName().equals("int")) res[i] = Integer.valueOf(rand.nextInt(MAXINT)); + else if (types[i].getName().equals("long")) res[i] = Long.valueOf(rand.nextInt(MAXINT)); + else if (types[i].getName().equals("short")) res[i] = Short.valueOf((short) rand.nextInt(MAXSHORT)); + else if (types[i].getName().equals("boolean")) res[i] = Boolean.valueOf(rand.nextBoolean()); + else if (types[i].getName().equals("[C")) res[i] = generateCharArray(); + else if (types[i].getName().equals("java.lang.String")) res[i] = generateString(); + else if (types[i].getName().equals("java.lang.StringBuffer")) res[i] = generateStringBuffer(); + else if (types[i].getName().equals("java.lang.CharSequence")) res[i] = generateString(); + else if (types[i].getName().equals("it.unimi.dsi.lang.MutableString")) res[i] = generateMutableString(); + else if (types[i].getName().equals("java.lang.Object")) res[i] = new Object(); + else throw new IllegalArgumentException("Type " + types[i] + " not (yet) implemented"); + } + return res; + } + + /** Generates a char[] at random. */ + public static char[] generateCharArray() { + return generateCharArray(MAXLENGTH); + } + + /** Generates a char[] at random with given its maximum length. */ + public static char[] generateCharArray(final int m) { + final int n = rand.nextInt(m + 1); + final char res[] = new char[n]; + for (int i = 0; i < n; i++) res[i] = rand.nextInt(SPACE_FREQ) == 0 ? ' ' : (char) (MINCHAR + rand.nextInt(MAXCHAR - MINCHAR + 1)); + return res; + } + + /** Generates a char[] at random. */ + public static char[] generateUnicodeCharArray(final int n) { + final char res[] = new char[n]; + for (int i = 0; i < n; i++) while (! Character.isLetterOrDigit(res[i] = (char)rand.nextInt())); + return res; + } + + /** Generates a String at random. */ + public static String generateString() { + return new String(generateCharArray()); + } + + /** Generates a StringBuffer at random. */ + public static StringBuffer generateStringBuffer() { + return new StringBuffer(new String(generateCharArray())); + } + + /** Generates a MutableString at random. */ + public static MutableString generateMutableString() { + return new MutableString(generateCharArray()); + } + + + /** Converts Object <code>o</code> from class <code>c1</code> to class <code>c2</code>. */ + public static Object convert(final Object o, final Class<? extends Object> c1, final Class c2) { + if (c1.equals(c2)) return o; + if (Number.class.isAssignableFrom(c1)) return o; + if (c1.equals(MutableString.class)) { + if (c2.equals(String.class)) return ((MutableString)o).toString(); + else if (c2.equals(StringBuffer.class)) return new StringBuffer(((MutableString)o).toString()); + } + else if (c1.equals(StringBuffer.class)) { + if (c2.equals(String.class)) return ((StringBuffer)o).toString(); + } + else if (c1.equals(CharSequence.class)) { + if (c2.equals(String.class)) return ((CharSequence)o).toString(); + } + else if (c1.equals(Character.class)) { + if (c2.equals(String.class)) return o.toString(); + } + System.err.println("Don't know how to convert " + c1 + " to " + c2); + System.err.println("(Object to convert is " + o + ")"); + System.exit(1); + return null; + } + + /** Given an array of Objects, it converts their types using <code>alternativeParameterType</code> array, unless + * the latter is {@code null}, in which case it just returns a copy of the argument. */ + public static Object[] convert(final Object arg[]) { + final int n = arg.length; + final Object res[] = new Object[n]; + if (alternativeParameterType == null) { + System.arraycopy(arg, 0, res, 0, n); + return res; + } + assert n == alternativeParameterType.length; + for (int i = 0; i < n; i++) + res[i] = convert(arg[i], arg[i].getClass(), alternativeParameterType[i]); + return res; + } + + private static void print(final String type, final String name, final CharSequence s) { + System.out.println(type + " content of " + name + " was"); + System.out.println(s + " [" + s.length() + " chars]"); + System.out.println(CharArrayList.wrap(new MutableString(s).toCharArray())); + System.out.print("["); + for(int i = 0; i < s.length(); i++) System.out.print((int)s.charAt(i) + (i == 0 ? "" : ", ")); + System.out.println("]"); + } + + private static void print2(final String type, final String sb, final String ms) { + print(type, "StringBuffer", sb); + print(type, "MutableString", ms); + } + + final static int NUMBER_OF_SPECIAL_TESTS = 23; // Number of special tests, to be updated manually. + final static int NUMBER_OF_TESTS = 100; // Number of public methods, to be updated manually. + + /** Special tests... */ + public static void specialTest(final StringBuffer sb, MutableString ms) { + Object msRes = null, sbRes = null; + Exception msThrow = null, sbThrow = null; + Method msm = null; + int which, choice, from; + + String ssb = new String(sb.toString()); + final String sms = new String(ms.toString()); + Object o; + StringBuffer b; + char c, d, a[]; + String s; + boolean compact = ms.isCompact(); + + which = rand.nextInt(NUMBER_OF_SPECIAL_TESTS); + try { + switch (which) { + case 0: + // toLowerCase + try { ms.toLowerCase(); } catch (final Exception e) { msThrow = e; } + try { sb.setLength(0); sb.append(ssb.toString().toLowerCase()); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("toLowerCase", new Class[] {}); + break; + case 1: + // toUpperCase + try { ms.toUpperCase(); } catch (final Exception e) { msThrow = e; } + try { sb.setLength(0); sb.append(ssb.toString().toUpperCase()); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("toUpperCase", new Class[] {}); + break; + case 2: + // trim + try { ms.trim(); } catch (final Exception e) { msThrow = e; } + try { sb.setLength(0); sb.append(ssb.toString().trim()); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("trim", new Class[] {}); + break; + case 20: + // trimLeft + try { ms.trimLeft(); } catch (final Exception e) { msThrow = e; } + try { sb.setLength(0); sb.append((ssb.toString() + "X").trim()); sb.deleteCharAt(sb.length() - 1); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("trimLeft", new Class[] {}); + break; + case 21: + // trimRight + try { ms.trimRight(); } catch (final Exception e) { msThrow = e; } + try { sb.setLength(0); sb.append(("X" + ssb.toString()).trim().substring(1)); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("trimRight", new Class[] {}); + break; + case 3: + // lastChar + try { msRes = Character.valueOf(ms.lastChar()); } catch (final Exception e) { msThrow = e; } + try { sbRes = Character.valueOf(sb.toString().charAt(sb.length()-1)); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("lastChar", new Class[] {}); + break; + case 4: + // firstChar + try { msRes = Character.valueOf(ms.firstChar()); } catch (final Exception e) { msThrow = e; } + try { sbRes = Character.valueOf(sb.toString().charAt(0)); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("firstChar", new Class[] {}); + break; + case 5: + // loose + try { ms.loose(); } catch (final Exception e) {} + msm = MutableString.class.getDeclaredMethod("loose", new Class[] {}); + break; + case 6: + // compact + try { ms.compact(); } catch (final Exception e) {} + if (ms.capacity() != ms.length()) { + System.err.println("After compact, MutableString does not appear to be compact"); + print("Current", "MutableString", ms); + print("Previous", "MutableString", sms); + System.err.println("Capacity=" + ms.capacity() + ", length=" + ms.length()); + System.exit(1); + } + msm = MutableString.class.getDeclaredMethod("compact", new Class[] {}); + break; + case 7: + // array + try { msRes = (CharArrayList.wrap(ms.array())).subList(0, ms.length()); } catch (final Exception e) { msThrow = e; } + try { sbRes = CharArrayList.wrap(sb.toString().toCharArray()); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("array", new Class[] {}); + break; + case 8: + // changed + ms.compact(); + compact = true; + a = ms.array(); + msm = MutableString.class.getDeclaredMethod("changed", new Class[] {}); + if (sb.length() == 0) break; + final int changeHowMany = rand.nextInt(sb.length()); + int pos; + for (int i = 0; i < changeHowMany; i++) { + c = a[pos = rand.nextInt(sb.length())] = (char) (MINCHAR + rand.nextInt(MAXCHAR - MINCHAR + 1)); + sb.setCharAt(pos, c); + } + ms.changed(); + break; + case 9: + // wrap + if (ms.isCompact()) { + try { + ms = MutableString.wrap(ms.array()); + } catch (final Exception e) {} + msm = MutableString.class.getDeclaredMethod("wrap", new Class[] { char[].class }); + } + else { + try { + ms = MutableString.wrap(ms.array(), ms.length()); + } catch (final Exception e) {} + msm = MutableString.class.getDeclaredMethod("wrap", new Class[] { char[].class, int.class }); + } + break; + case 10: + // equals + if (! ms.equals(new MutableString(sb))) { + System.err.println("equals(MutableString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + new MutableString(sb)); + System.exit(1); + } + if (! ms.equals(new MutableString(ssb.toCharArray()))) { + System.err.println("equals(char[]) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + CharArrayList.wrap(ssb.toCharArray())); + System.exit(1); + } + if (! ms.equals(sb.toString())) { + System.err.println("equals(String) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + sb); + System.exit(1); + } + ssb = ssb.intern(); + if (! ms.equals(ssb)) { + System.err.println("equals(String.intern()) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + ssb); + System.exit(1); + } + + o = sb; + if (! ms.equals(o)) { + System.err.println("equals(Object=MutableString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + new MutableString(sb)); + System.exit(1); + } + o = sb.toString(); + if (! ms.equals(o)) { + System.err.println("equals(Object=String) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + sb); + System.exit(1); + } + o = ssb.intern(); + if (! ms.equals(o)) { + System.err.println("equals(Object=String.intern()) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + ssb); + System.exit(1); + } + + b = new StringBuffer(sb.toString()).append(' '); + if (ms.equals(new MutableString(b))) { + System.err.println("! equalsMutableString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + new MutableString(b)); + System.exit(1); + } + if (ms.equals(new MutableString(b.toString().toCharArray()))) { + System.err.println("! equalschar[]) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + CharArrayList.wrap(b.toString().toCharArray())); + System.exit(1); + } + if (ms.equals(b.toString())) { + System.err.println("! equalsString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + b); + System.exit(1); + } + s = b.toString().intern(); + if (ms.equals(s)) { + System.err.println("! equalsString.intern()) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + s); + System.exit(1); + } + + o = b; + if (ms.equals(o)) { + System.err.println("! equals(Object=MutableString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + o); + System.exit(1); + } + o = b.toString(); + if (ms.equals(o)) { + System.err.println("! equals(Object=String) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + o); + System.exit(1); + } + o = b.toString().intern(); + if (ms.equals(o)) { + System.err.println("! equals(Object=String.intern()) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + o); + System.exit(1); + } + msm = MutableString.class.getDeclaredMethod("equals", new Class[] { Object.class }); + break; + case 11: + // equalsIgnoreCase + b = new StringBuffer(new String(sb).toUpperCase()); + s = b.toString(); + if (! ms.equalsIgnoreCase(new MutableString(b))) { + System.err.println("equalsIgnoreCase(MutableString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + new MutableString(b)); + System.exit(1); + } + if (! ms.equalsIgnoreCase(new MutableString(s.toCharArray()))) { + System.err.println("equalsIgnoreCase(char[]) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + CharArrayList.wrap(s.toCharArray())); + System.exit(1); + } + if (! ms.equalsIgnoreCase(s.toString())) { + System.err.println("equalsIgnoreCase(String) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + s); + System.exit(1); + } + ssb = ssb.intern(); + if (! ms.equalsIgnoreCase(ssb)) { + System.err.println("equalsIgnoreCase(String.intern()) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + ssb); + System.exit(1); + } + + b = new StringBuffer(new String(sb).toUpperCase()).append(' '); + if (ms.equalsIgnoreCase(new MutableString(b))) { + System.err.println("! equalsIgnoreCaseMutableString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + new MutableString(b)); + System.exit(1); + } + if (ms.equalsIgnoreCase(new MutableString(b.toString().toCharArray()))) { + System.err.println("! equalsIgnoreCasechar[]) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + CharArrayList.wrap(b.toString().toCharArray())); + System.exit(1); + } + if (ms.equalsIgnoreCase(b.toString())) { + System.err.println("! equalsIgnoreCaseString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + b); + System.exit(1); + } + s = b.toString().intern(); + if (ms.equalsIgnoreCase(s)) { + System.err.println("! equalsIgnoreCaseString.intern()) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + s); + System.exit(1); + } + + msm = MutableString.class.getDeclaredMethod("equalsIgnoreCase", new Class[] { MutableString.class }); + break; + case 12: + // compareTo + if (0 != ms.compareTo(new MutableString(sb))) { + System.err.println("compareTo(MutableString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + new MutableString(sb)); + System.exit(1); + } + if (0 != ms.compareTo(new MutableString(ssb.toCharArray()))) { + System.err.println("compareTo(char[]) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + CharArrayList.wrap(ssb.toCharArray())); + System.exit(1); + } + if (0 != ms.compareTo(sb.toString())) { + System.err.println("compareTo(String) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + sb); + System.exit(1); + } + ssb = ssb.intern(); + if (0 != ms.compareTo(ssb)) { + System.err.println("compareTo(String.intern()) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + ssb); + System.exit(1); + } + + o = sb; + + b = new StringBuffer(sb.toString()); + if (b.length() == 0) { + b.append(d = 'A'); + c = 0; + } + else { + final int p = rand.nextInt(b.length()); + c = b.charAt(p); + d = (char)(c + rand.nextInt(2) * 2 - 1); + } + if (0 < (d - c) * ms.compareTo(new MutableString(b))) { + System.err.println("! compareTo(MutableString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + new MutableString(b)); + System.exit(1); + } + if (0 < (d - c) * ms.compareTo(new MutableString(b.toString().toCharArray()))) { + System.err.println("! compareTo(char[]) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + CharArrayList.wrap(b.toString().toCharArray())); + System.exit(1); + } + if (0 < (d - c) * ms.compareTo(b.toString())) { + System.err.println("! compareTo(String) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + b); + System.exit(1); + } + s = b.toString().intern(); + if (0 < (d - c) * ms.compareTo(s)) { + System.err.println("! compareTo(String.intern()) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + s); + System.exit(1); + } + + msm = MutableString.class.getDeclaredMethod("compareTo", new Class[] { MutableString.class }); + break; + case 13: + // compareToIgnoreCase + if (0 != ms.compareToIgnoreCase(new MutableString(sb))) { + System.err.println("compareToIgnoreCase(MutableString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + new MutableString(sb)); + System.exit(1); + } + if (0 != ms.compareToIgnoreCase(new MutableString(ssb.toCharArray()))) { + System.err.println("compareToIgnoreCase(char[]) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + CharArrayList.wrap(ssb.toCharArray())); + System.exit(1); + } + if (0 != ms.compareToIgnoreCase(sb.toString())) { + System.err.println("compareToIgnoreCase(String) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + sb); + System.exit(1); + } + ssb = ssb.intern(); + if (0 != ms.compareToIgnoreCase(ssb)) { + System.err.println("compareToIgnoreCase(String.intern()) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + ssb); + System.exit(1); + } + + b = new StringBuffer(sb.toString()); + if (b.length() == 0) { + b.append(d = 'A'); + c = 0; + } + else { + final int p = rand.nextInt(b.length()); + c = b.charAt(p); + d = (char)(c + rand.nextInt(2) * 2 - 1); + } + if (0 < (d - c) * ms.compareToIgnoreCase(new MutableString(b))) { + System.err.println("! compareToIgnoreCase(MutableString) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + new MutableString(b)); + System.exit(1); + } + if (0 < (d - c) * ms.compareToIgnoreCase(new MutableString(b.toString().toCharArray()))) { + System.err.println("! compareToIgnoreCase(char[]) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + CharArrayList.wrap(b.toString().toCharArray())); + System.exit(1); + } + if (0 < (d - c) * ms.compareToIgnoreCase(b.toString())) { + System.err.println("! compareToIgnoreCase(String) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + b); + System.exit(1); + } + s = b.toString().intern(); + if (0 < (d - c) * ms.compareToIgnoreCase(s)) { + System.err.println("! compareToIgnoreCase(String.intern()) failed"); + System.err.println("MutableString is " + ms); + System.err.println("Argument is " + s); + System.exit(1); + } + + msm = MutableString.class.getDeclaredMethod("compareToIgnoreCase", new Class[] { MutableString.class }); + break; + case 14: + // replace + choice = rand.nextInt(9); + + int l = choice > 4 ? 1 : rand.nextInt(40); + a = new char[l]; + for(int i = 0; i < l; i++) a[i] = (char)('@' + i); + + final MutableString as[] = new MutableString[a.length]; + + b = new StringBuffer(); + for(int i = 0; i < a.length; i++) as[i] = generateMutableString().length(choice == 3 || choice == 4 || choice == 8 ? 1 : 1 + rand.nextInt(4)); + for(int i = 0; i < sb.length(); i++) { + int j; + for(j = 0; j < a.length; j++) { + if (sb.charAt(i) == a[j]) { + b.append(as[j]); + break; + } + } + if (j == a.length) b.append(sb.charAt(i)); + } + sb.setLength(0); + sb.append(b); + + switch(choice) { + case 0: ms.replace(a, as); + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { char[].class, MutableString[].class }); break; + case 1: final String badString[] = new String[as.length]; for(int i = 0; i < as.length; i++) badString[i] = as[i].toString(); ms.replace(a, badString); + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { char[].class, String[].class }); break; + case 2: final CharSequence badCS[] = new CharSequence[as.length]; for(int i = 0; i < as.length; i++) badCS[i] = as[i]; ms.replace(a, badCS); + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { char[].class, CharSequence[].class }); break; + case 3: final char badChar[] = new char[as.length]; for(int i = 0; i < as.length; i++) badChar[i] = as[i].charAt(0); ms.replace(a, badChar); + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { char[].class, char[].class }); break; + case 4: final Char2CharOpenHashMap m = new Char2CharOpenHashMap(); for(int i = 0; i < as.length; i++) m.put(a[i], as[i].charAt(0)); ms.replace(m); + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { Char2CharMap.class }); break; + case 5: ms.replace(a[0], as[0]); + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { char.class, MutableString.class }); break; + case 6: final String badString1 = as[0].toString(); ms.replace(a[0], badString1); + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { char.class, String.class }); break; + case 7: final CharSequence badCS1 = as[0]; ms.replace(a[0], badCS1); + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { char.class, CharSequence.class }); break; + case 8: ms.replace(a[0], as[0].charAt(0)); + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { char.class, char.class }); break; + } + + break; + + case 15: + // + choice = rand.nextInt(6); + l = rand.nextInt(ms.length() + 1); + s = sb.toString().substring(0, l); + if (choice >= 3 && choice < 6) s = s.toLowerCase(); + if (choice > 5) s = new String(generateCharArray(l)); + + switch(choice % 6) { + case 0: + try { msRes = Boolean.valueOf(ms.startsWith(ms.substring(0, l))); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().startsWith(s)); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("startsWith", new Class[] { MutableString.class }); + break; + + case 1: + try { msRes = Boolean.valueOf(ms.startsWith(ms.substring(0, l).toString())); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().startsWith(s)); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("startsWith", new Class[] { String.class }); + break; + + case 2: + try { msRes = Boolean.valueOf(ms.startsWith(new StringBuffer(ms.substring(0, l).toString()))); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().startsWith(s)); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("startsWith", new Class[] { CharSequence.class }); + break; + + case 3: + try { msRes = Boolean.valueOf(ms.startsWithIgnoreCase(ms.substring(0, l))); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().toLowerCase().startsWith(s.toLowerCase())); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("startsWithIgnoreCase", new Class[] { MutableString.class }); + break; + + case 4: + try { msRes = Boolean.valueOf(ms.startsWithIgnoreCase(ms.substring(0, l).toString())); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().toLowerCase().startsWith(s.toLowerCase())); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("startsWithIgnoreCase", new Class[] { String.class }); + break; + + case 5: + try { msRes = Boolean.valueOf(ms.startsWithIgnoreCase(new StringBuffer(ms.substring(0, l).toString()))); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().toLowerCase().startsWith(s.toLowerCase())); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("startsWithIgnoreCase", new Class[] { CharSequence.class }); + break; + + } + break; + + case 16: + // + choice = rand.nextInt(6); + l = rand.nextInt(ms.length() + 1); + s = sb.toString().substring(sb.length() - l); + if (choice >= 3 && choice < 6) s = s.toLowerCase(); + if (choice > 5) s = new String(generateCharArray(l)); + + switch(choice % 6) { + case 0: + try { msRes = Boolean.valueOf(ms.endsWith(ms.substring(l))); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().endsWith(s)); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("endsWith", new Class[] { MutableString.class }); + break; + + case 1: + try { msRes = Boolean.valueOf(ms.endsWith(ms.substring(l).toString())); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().endsWith(s)); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("endsWith", new Class[] { String.class }); + break; + + case 2: + try { msRes = Boolean.valueOf(ms.endsWith(new StringBuffer(ms.substring(l).toString()))); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().endsWith(s)); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("endsWith", new Class[] { CharSequence.class }); + break; + + case 3: + try { msRes = Boolean.valueOf(ms.endsWithIgnoreCase(ms.substring(l))); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().toLowerCase().endsWith(s.toLowerCase())); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("endsWithIgnoreCase", new Class[] { MutableString.class }); + break; + + case 4: + try { msRes = Boolean.valueOf(ms.endsWithIgnoreCase(ms.substring(l).toString())); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().toLowerCase().endsWith(s.toLowerCase())); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("endsWithIgnoreCase", new Class[] { String.class }); + break; + + case 5: + try { msRes = Boolean.valueOf(ms.endsWithIgnoreCase(new StringBuffer(ms.substring(l).toString()))); } catch (final Exception e) { msThrow = e; } + try { sbRes = Boolean.valueOf(sb.toString().toLowerCase().endsWith(s.toLowerCase())); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("endsWithIgnoreCase", new Class[] { CharSequence.class }); + break; + + } + break; + + case 17: + // + l = rand.nextInt(sb.length()/2 + 1); + if (rand.nextBoolean()) s = new String(generateCharArray(l)); + else s = sb.toString().substring(l, l + rand.nextInt(sb.length()/4 + 1)); + + from = rand.nextInt() % (sb.length() * 2 + 1); + + switch(rand.nextInt(8)) { + case 0: + try { msRes = Integer.valueOf(ms.indexOf(s, from)); } catch (final Exception e) { msThrow = e; } + try { sbRes = Integer.valueOf(new TextPattern(s).search(sb, from)); } catch (final Exception e) { sbThrow = e; } + // This is a fake, we really checked TextPattern + msm = MutableString.class.getDeclaredMethod("indexOf", new Class[] { MutableString.class }); + break; + case 1: + try { msRes = Integer.valueOf(ms.indexOf(s, from)); } catch (final Exception e) { msThrow = e; } + try { sbRes = Integer.valueOf(new TextPattern(s).search(ms, from)); } catch (final Exception e) { sbThrow = e; } + // This is a fake, we really checked TextPattern + msm = MutableString.class.getDeclaredMethod("indexOf", new Class[] { MutableString.class }); + break; + case 2: + a = s.toCharArray(); + try { msRes = Integer.valueOf(ms.indexOfAnyOf(a, from)); } catch (final Exception e) { msThrow = e; } + try { + int temp = Integer.MAX_VALUE; + for (final char element : a) if ((pos = sms.indexOf(element, from)) != -1) temp = Math.min(temp, pos); + sbRes = Integer.valueOf(temp == Integer.MAX_VALUE ? -1 : temp); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("indexOfAnyOf", new Class[] { char[].class }); + break; + case 3: + a = s.toCharArray(); + //System.err.println(CharArrayList.wrap(a) + " " + from); + try { msRes = Integer.valueOf(ms.indexOfAnyBut(a, from)); } catch (final Exception e) { msThrow = e; } + try { + int i; + if (from < 0) from = 0; + if (from > ms.length()) from = ms.length(); + for (i = from; i < ms.length(); i++) { + int j; + for(j = 0; j < a.length; j++) if (ms.charAt(i) == a[j]) break; + if (j == a.length) break; + } + sbRes = Integer.valueOf(i < ms.length() ? i : -1); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("indexOfAnyBut", new Class[] { char[].class }); + break; + + case 4: + a = s.toCharArray(); + try { msRes = Integer.valueOf(ms.indexOfAnyOf(new CharOpenHashSet(a), from)); } catch (final Exception e) { msThrow = e; } + try { + int temp = Integer.MAX_VALUE; + for (final char element : a) if ((pos = sms.indexOf(element, from)) != -1) temp = Math.min(temp, pos); + sbRes = Integer.valueOf(temp == Integer.MAX_VALUE ? -1 : temp); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("indexOfAnyOf", new Class[] { CharSet.class }); + break; + + case 5: + a = s.toCharArray(); + //System.err.println(CharArrayList.wrap(a) + " " + from); + try { msRes = Integer.valueOf(ms.indexOfAnyBut(new CharOpenHashSet(a), from)); } catch (final Exception e) { msThrow = e; } + try { + int i; + if (from < 0) from = 0; + if (from > ms.length()) from = ms.length(); + for (i = from; i < ms.length(); i++) { + int j; + for(j = 0; j < a.length; j++) if (ms.charAt(i) == a[j]) break; + if (j == a.length) break; + } + sbRes = Integer.valueOf(i < ms.length() ? i : -1); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("indexOfAnyBut", new Class[] { CharSet.class }); + break; + + case 6: + a = s.toCharArray(); + //System.err.println(CharArrayList.wrap(a) + " " + from); + try { msRes = Integer.valueOf(ms.span(a, from)); } catch (final Exception e) { msThrow = e; } + try { + int i; + if (from < 0) from = 0; + if (from > ms.length()) from = ms.length(); + for (i = from; i < ms.length(); i++) { + int j; + for(j = 0; j < a.length; j++) if (ms.charAt(i) == a[j]) break; + if (j == a.length) break; + } + sbRes = Integer.valueOf(i - from); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("span", new Class[] { char[].class }); + break; + case 7: + a = s.toCharArray(); + //System.err.println(CharArrayList.wrap(a) + " " + from); + try { msRes = Integer.valueOf(ms.span(new CharOpenHashSet(a), from)); } catch (final Exception e) { msThrow = e; } + try { + int i; + if (from < 0) from = 0; + if (from > ms.length()) from = ms.length(); + for (i = from; i < ms.length(); i++) { + int j; + for(j = 0; j < a.length; j++) if (ms.charAt(i) == a[j]) break; + if (j == a.length) break; + } + sbRes = Integer.valueOf(i - from); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("span", new Class[] { CharSet.class }); + break; + } + break; + + case 18: + String search; + String replace; + main: for(;;) { + search = new String(generateCharArray(rand.nextInt(10))); + replace = new String(generateCharArray(rand.nextInt(10))); + if (search.length() == 0) search = search + "X"; + if (replace.length() <= search.length()) break; + /* Skip search strings with overlapping matches if replace text is longer than search text, as the semantics is + * slightly different (see replace()'s documentation). */ + int i = -1; + int prev = -search.length(); + for(;;) { + i = ms.indexOf(search, i + 1); + if (i == -1) break main; + if (prev + search.length() > i) break; + prev = i; + } + } + + try { s = new String(sb).replaceAll(search, replace); sb.setLength(0); sb.append(s); } catch (final Exception e) { sbThrow = e; } + + switch(rand.nextInt(3)) { + case 0: + try { ms.replace(new MutableString(search), new MutableString(replace)); } catch (final Exception e) { msThrow = e; } + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { MutableString.class, MutableString.class }); + break; + case 1: + try { ms.replace(search, replace); } catch (final Exception e) { msThrow = e; } + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { String.class, String.class }); + break; + case 2: + final CharSequence s1 = search, r1 = replace; + try { ms.replace(s1, r1); } catch (final Exception e) { msThrow = e; } + msm = MutableString.class.getDeclaredMethod("replace", new Class[] { CharSequence.class, CharSequence.class }); + break; + } + + break; + + case 19: + // + l = rand.nextInt(sb.length()/2 + 1); + if (rand.nextBoolean()) s = new String(generateCharArray(l)); + else s = sb.toString().substring(l, l + rand.nextInt(sb.length()/4 + 1)); + + from = rand.nextInt() % (sb.length() * 2 + 1); + + switch(rand.nextInt(7)) { + case 0: + try { msRes = Integer.valueOf(ms.lastIndexOf(s, from)); } catch (final Exception e) { msThrow = e; } + try { sbRes = Integer.valueOf(sb.lastIndexOf(s ,from)); } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("lastIndexOf", new Class[] { MutableString.class }); + break; + case 1: + a = s.toCharArray(); + try { msRes = Integer.valueOf(ms.lastIndexOfAnyOf(a, from)); } catch (final Exception e) { msThrow = e; } + try { + int temp = Integer.MIN_VALUE; + for (final char element : a) { + if ((pos = sms.lastIndexOf(element, from)) != -1) temp = Math.max(temp, pos); + } + sbRes = Integer.valueOf(temp == Integer.MIN_VALUE ? -1 : temp); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("lastIndexOfAnyOf", new Class[] { char[].class }); + break; + case 2: + a = s.toCharArray(); + //System.err.println(CharArrayList.wrap(a) + " " + from); + try { msRes = Integer.valueOf(ms.lastIndexOfAnyBut(a, from)); } catch (final Exception e) { msThrow = e; } + try { + int i; + if (from < 0) from = -1; + if (from >= ms.length()) from = ms.length() - 1; + for (i = from; i >= 0; i--) { + int j; + for(j = 0; j < a.length; j++) if (ms.charAt(i) == a[j]) break; + if (j == a.length) break; + } + sbRes = Integer.valueOf(i); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("lastIndexOfAnyBut", new Class[] { char[].class }); + break; + + case 3: + a = s.toCharArray(); + try { msRes = Integer.valueOf(ms.lastIndexOfAnyOf(new CharOpenHashSet(a), from)); } catch (final Exception e) { msThrow = e; } + try { + int temp = Integer.MIN_VALUE; + for (final char element : a) { + if ((pos = sms.lastIndexOf(element, from)) != -1) temp = Math.max(temp, pos); + } + sbRes = Integer.valueOf(temp == Integer.MIN_VALUE ? -1 : temp); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("lastIndexOfAnyOf", new Class[] { CharSet.class }); + break; + + case 4: + a = s.toCharArray(); + //System.err.println(CharArrayList.wrap(a) + " " + from); + try { msRes = Integer.valueOf(ms.lastIndexOfAnyBut(new CharOpenHashSet(a), from)); } catch (final Exception e) { msThrow = e; } + try { + int i; + if (from < 0) from = -1; + if (from >= ms.length()) from = ms.length() - 1; + for (i = from; i >= 0; i--) { + int j; + for(j = 0; j < a.length; j++) if (ms.charAt(i) == a[j]) break; + if (j == a.length) break; + } + sbRes = Integer.valueOf(i); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("lastIndexOfAnyBut", new Class[] { CharSet.class }); + break; + case 5: + a = s.toCharArray(); + //System.err.println(CharArrayList.wrap(a) + " " + from); + try { msRes = Integer.valueOf(ms.cospan(a, from)); } catch (final Exception e) { msThrow = e; } + try { + int i; + if (from < 0) from = 0; + if (from > ms.length()) from = ms.length(); + for (i = from; i < ms.length(); i++) { + int j; + for(j = 0; j < a.length; j++) if (ms.charAt(i) == a[j]) break; + if (j != a.length) break; + } + sbRes = Integer.valueOf(i - from); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("cospan", new Class[] { char[].class }); + break; + case 6: + a = s.toCharArray(); + //System.err.println(CharArrayList.wrap(a) + " " + from); + try { msRes = Integer.valueOf(ms.cospan(new CharOpenHashSet(a), from)); } catch (final Exception e) { msThrow = e; } + try { + int i; + if (from < 0) from = 0; + if (from > ms.length()) from = ms.length(); + for (i = from; i < ms.length(); i++) { + int j; + for(j = 0; j < a.length; j++) if (ms.charAt(i) == a[j]) break; + if (j != a.length) break; + } + sbRes = Integer.valueOf(i - from); + } catch (final Exception e) { sbThrow = e; } + msm = MutableString.class.getDeclaredMethod("cospan", new Class[] { CharSet.class }); + break; + } + break; + + case 22: + // delete characters + choice = rand.nextInt(3); + + l = choice == 0 ? 1 : rand.nextInt(40); + a = new char[l]; + for(int i = 0; i < l; i++) a[i] = (char)('@' + rand.nextInt('Z' - '@')); + final CharOpenHashSet charSet = new CharOpenHashSet(a); + + for(int i = 0; i < sb.length();) if (charSet.contains(sb.charAt(i))) sb.delete(i, i + 1); else i++; + + switch(choice) { + case 0: ms.delete(a[0]); + msm = MutableString.class.getDeclaredMethod("delete", new Class[] { char.class }); break; + case 1: ms.delete(a); + msm = MutableString.class.getDeclaredMethod("delete", new Class[] { char[].class }); break; + case 2: ms.delete(charSet); + msm = MutableString.class.getDeclaredMethod("delete", new Class[] { CharSet.class }); break; + } + break; + + default: + System.err.println("Special test number " + which + " not (yet) defined"); + System.exit(1); + } + } catch (final Exception e) { + e.printStackTrace(); + System.exit(1); + } + + if (sbThrow == null && msThrow != null) { + System.out.println("Method " + msm + " threw exception " + msThrow); + System.out.println("No exception was thrown by StringBuffer"); + print2("Previous", ssb, sms); + System.exit(1); + } + + if (sbThrow != null && msThrow == null) { + System.out.println("Method " + msm + " threw no exception "); + System.out.println("StringBuffer threw " + sbThrow); + print2("Previous", ssb, sms); + System.exit(1); + } + + if (sbThrow != null && msThrow != null && ! (msThrow.getClass().equals(msThrow.getClass()))) { + System.out.println("Method " + msm + " threw " + msThrow); + System.out.println("StringBuffer threw " + sbThrow); + print2("Previous", ssb, sms); + System.exit(1); + } + + for (msIdx = 0; msIdx < msMethod.length; msIdx++) if (msMethod[msIdx].equals(msm)) break; + if (msIdx == msMethod.length) { + throw new IllegalStateException("I was looking for " + msm + " (which = " + which + ")"); + } + msTimes[msIdx]++; + + if (sbThrow != null) { + msExc[msIdx]++; + } + + if (which != 6 && which != 5 && ms.isCompact() != compact) { + System.out.println("On method " + msm); + System.out.println("Previously MutableString was " + (compact ? "compact" : "loose") + "; now it is " + (ms.isCompact() ? "compact" : "loose")); + if (sbThrow != null) System.out.println("The method produced an " + sbThrow); + System.exit(1); + } + + if ((msRes == null && sbRes != null) || (msRes != null && sbRes == null) || (msRes != null && ! (msRes.equals(sbRes)))) { + System.out.println("On method " + msm + " returned value was " + msRes); + System.out.println("StringBuffer returned " + sbRes + " instead"); + System.out.println("Class of first result: " + sbRes.getClass() + " hashcode=" + sbRes.hashCode()); + System.out.println("Class of second result: " + msRes.getClass() + " hashcode=" + msRes.hashCode()); + System.out.println("The two results are equal? " + msRes.equals(sbRes)); + System.out.println("The two results (as Strings) are equal? " + msRes.toString().equals(sbRes.toString())); + print2("Previous", ssb, sms); + if (msThrow != null) System.out.println("The MutableString method produced an " + msThrow); + if (sbThrow != null) System.out.println("The StringBuffer method produced an " + sbThrow); + System.exit(1); + } + + if (! (sb.toString().equals(ms.toString()))) { + System.out.println("After call, values are different"); + System.out.println("Method " + msm); + print2("Previous", ssb, sms); + print("Current", "StringBuffer", sb); + print("Current", "MutableString", ms); + int i; + for(i = 0; i < Math.min(sb.length(), ms.length()); i++) if (sb.charAt(i) != ms.charAt(i)) break; + System.out.println("First different character has index " + i); + if (msThrow != null) System.out.println("The MutableString method produced an " + msThrow); + if (sbThrow != null) System.out.println("The StringBuffer method produced an " + sbThrow); + System.exit(1); + } + + + + } + + + /** Tests I/O methods. */ + @SuppressWarnings("deprecation") + public static void testIO(final int n) throws IOException { + final MutableString a[] = new MutableString[n], t = new MutableString(); + final int l[] = new int[n]; + + // I/O on data input/output + DataOutputStream dbos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("regressionTest"))); + for(int i = 0; i < n; i++) { + if (rand.nextBoolean()) l[i] = rand.nextInt(100); + else l[i] = rand.nextInt(100000); + (a[i] = new MutableString(generateUnicodeCharArray(l[i]))).writeSelfDelimUTF8((DataOutput)dbos); + } + dbos.close(); + + DataInputStream dbis = new DataInputStream(new BufferedInputStream(new FileInputStream("regressionTest"))); + for(int i = 0; i < n; i++) if (! a[i].equals(t.readSelfDelimUTF8((DataInput)dbis))) { + System.out.println("On I/O with self-delimiting UTF-8 (" + i + ")"); + System.out.println("Written was " + s2i(a[i])); + System.out.println("Read is " + s2i(t)); + System.exit(1); + } + dbis.close(); + + dbos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("regressionTest"))); + for(int i = 0; i < n; i++) { + if (rand.nextBoolean()) l[i] = rand.nextInt(100); + else l[i] = rand.nextInt(100000); + (a[i] = new MutableString(generateUnicodeCharArray(l[i]))).writeUTF8((DataOutput)dbos); + } + dbos.close(); + + dbis = new DataInputStream(new BufferedInputStream(new FileInputStream("regressionTest"))); + for(int i = 0; i < n; i++) if (! a[i].equals(t.readUTF8((DataInput)dbis, l[i]))) { + System.out.println("On I/O with UTF-8 (" + i + ")"); + System.out.println("Written was " + s2i(a[i])); + System.out.println("Read is " + s2i(t)); + System.exit(1); + } + dbis.close(); + + + // I/O on input/output streams + BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("regressionTest")); + for(int i = 0; i < n; i++) { + if (rand.nextBoolean()) l[i] = rand.nextInt(100); + else l[i] = rand.nextInt(100000); + (a[i] = new MutableString(generateUnicodeCharArray(l[i]))).writeSelfDelimUTF8(bos); + } + bos.close(); + + BufferedInputStream bis = new BufferedInputStream(new FileInputStream("regressionTest")); + for(int i = 0; i < n; i++) if (! a[i].equals(t.readSelfDelimUTF8(bis))) { + System.out.println("On I/O with self-delimiting UTF-8 (" + i + ")"); + System.out.println("Written was " + s2i(a[i])); + System.out.println("Read is " + s2i(t)); + System.exit(1); + } + bis.close(); + + bos = new BufferedOutputStream(new FileOutputStream("regressionTest")); + for(int i = 0; i < n; i++) { + if (rand.nextBoolean()) l[i] = rand.nextInt(100); + else l[i] = rand.nextInt(100000); + (a[i] = new MutableString(generateUnicodeCharArray(l[i]))).writeUTF8(bos); + } + bos.close(); + + bis = new BufferedInputStream(new FileInputStream("regressionTest")); + for(int i = 0; i < n; i++) if (! a[i].equals(t.readUTF8(bis, l[i]))) { + System.out.println("On I/O with UTF-8 (" + i + ")"); + System.out.println("Written was " + s2i(a[i])); + System.out.println("Read is " + s2i(t)); + System.exit(1); + } + bis.close(); + + + + + + final OutputStreamWriter osw = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream("regressionTest")), "UTF-16BE"); + for(int i = 0; i < n; i++) { + if (rand.nextBoolean()) l[i] = rand.nextInt(100); + else l[i] = rand.nextInt(100000); + (a[i] = new MutableString(generateUnicodeCharArray(l[i]))).write(osw); + } + osw.close(); + + final InputStreamReader isr = new InputStreamReader(new BufferedInputStream(new FileInputStream("regressionTest")), "UTF-16BE"); + int u; + for(int i = 0; i < n; i++) { + if ((u = t.read(isr, l[i])) != l [i]) { + System.out.println("I/O error on " + t + ": " + l[i] + " characters read, " + u + " characters written"); + } + if (! a[i].equals(t)) { + System.out.println("On I/O with Reader (" + i + ")"); + System.out.println("Written was " + s2i(a[i])); + System.out.println("Read is " + s2i(t)); + System.exit(1); + } + } + isr.close(); + } + + + /** Tests a method at random on <code>sb</code> and <code>ms</code>. */ + public static void test(final StringBuffer sb, final MutableString ms) throws IllegalArgumentException, IllegalAccessException { + if (rand.nextInt(NUMBER_OF_TESTS) < NUMBER_OF_SPECIAL_TESTS) { + specialTest(sb, ms); + return; + } + final String ssb = sb.toString(); + final String sms = ms.toString(); + final Method m = randomMethod(); + final Object msargs[] = params(m); + final Object sbargs[] = convert(msargs); + Object sbRes = null; + Object msRes = null; + Throwable sbThrow = null; + Throwable msThrow = null; + final boolean compact = ms.isCompact(); + + try { + sbRes = sbMethod[sbIdx].invoke(sb, sbargs); + } catch (final InvocationTargetException e) { + //System.err.println("Exception " + e + " on target StringBuffer"); + sbThrow = e.getTargetException(); + } + + try { + msRes = msMethod[msIdx].invoke(ms, msargs); + } catch (final InvocationTargetException e) { + //System.err.println("Exception " + e + " on target MutableString"); + msThrow = e.getTargetException(); + } + + if (sbThrow == null && msThrow != null) { + System.out.println("On method " + sbMethod[sbIdx] + " with args " + a2s(sbargs) + " threw no Exception"); + System.out.println("On method " + msMethod[msIdx] + " with args " + a2s(msargs) + " threw " + msThrow); + print2("Previous", ssb, sms); + System.exit(1); + } + + if (sbThrow != null && msThrow == null) { + System.out.println("On method " + sbMethod[sbIdx] + " with args " + a2s(sbargs) + " threw " + sbThrow); + System.out.println("On method " + msMethod[msIdx] + " with args " + a2s(msargs) + " threw no Exception"); + print2("Previous", ssb, sms); + System.exit(1); + } + + if (sbThrow != null && msThrow != null && ! (msThrow.getClass().equals(msThrow.getClass()))) { + System.out.println("On method " + sbMethod[sbIdx] + " with args " + a2s(sbargs) + " threw " + sbThrow); + System.out.println("On method " + msMethod[msIdx] + " with args " + a2s(msargs) + " threw " + msThrow); + print2("Previous", ssb, sms); + System.exit(1); + } + + sbTimes[sbIdx]++; + msTimes[msIdx]++; + + if (sbThrow != null) { + sbExc[sbIdx]++; + msExc[msIdx]++; + } + + if (m.getName().equals("capacity")) { + //System.err.println("Capacity of StringBuffer / MutableString: " + sbRes + " / " + msRes); + return; + } + + if (ms.isCompact() != compact && ! msMethod[msIdx].getName().equals("ensureCapacity")) { + System.out.println("On method " + msMethod[msIdx] + " with args " + a2s(msargs) + " returned " + msRes); + System.out.println("Previously MutableString was " + (compact ? "compact" : "loose") + "; now it is " + (ms.isCompact() ? "compact" : "loose")); + if (sbThrow != null) System.out.println("The method produced an " + sbThrow); + System.exit(1); + } + + if (sbMethod[sbIdx].getReturnType() != void.class && msMethod[msIdx].getReturnType() != void.class) { + + if ((msRes == null && sbRes != null) || (msRes != null && sbRes == null) || (msRes != null && ! (msRes.equals(sbRes)))) { + System.out.println("On method " + sbMethod[sbIdx] + " with args " + a2s(sbargs) + " returned " + sbRes); + System.out.println("On method " + msMethod[msIdx] + " with args " + a2s(msargs) + " returned " + msRes); + System.out.println("Class of first result: " + sbRes.getClass() + " hashcode=" + sbRes.hashCode()); + System.out.println("Class of second result: " + msRes.getClass() + " hashcode=" + msRes.hashCode()); + System.out.println("The two results are equal? " + msRes.equals(sbRes)); + System.out.println("The two results (as Strings) are equal? " + msRes.toString().equals(sbRes.toString())); + print2("Previous", ssb, sms); + if (sbThrow != null) System.out.println("The method produced an " + sbThrow); + System.exit(1); + } + + if (! (sb.toString().equals(ms.toString()))) { + System.out.println("After call, values are different"); + System.out.println("Method " + sbMethod[sbIdx] + " with args " + a2s(sbargs)); + System.out.println("Method " + msMethod[msIdx] + " with args " + a2s(msargs)); + print2("Previous", ssb, sms); + print("Current", "StringBuffer", sb); + print("Current", "MutableString", ms); + if (sbThrow != null) System.out.println("The call produced an " + sbThrow); + System.exit(1); + } + + } + + return; + } + + public static void main(final String[] arg) throws IllegalArgumentException, IllegalAccessException, IOException { + final int noOfTest = Integer.parseInt(arg[0]); + final int noOfIOTests = arg.length < 2 ? 100 : Integer.parseInt(arg[1]); + final long seed = arg.length < 3 ? System.currentTimeMillis() : Long.parseLong(arg[2]); + rand = new XoRoShiRo128PlusRandomGenerator(seed); + + System.out.println("Seed = " + seed); + + final char c[] = generateCharArray(); + final StringBuffer sb = new StringBuffer(new String(c)); + final MutableString ms = new MutableString(new String(c)); + + for(int i = 0; i < noOfTest; i++) test(sb, ms); + testIO(noOfIOTests); + + + System.out.println("\nStringBuffer Methods"); + for (int i = 0; i < sbMethod.length; i++) + System.out.println("\t" + sbMethod[i] + " called " + sbTimes[i] + " (exc. " + sbExc[i] + ")"); + System.out.println("\nMutableString Methods"); + for (int i = 0; i < msMethod.length; i++) + System.out.println("\t" + msMethod[i] + " called " + msTimes[i] + " (exc. " + msExc[i] + ")"); + } + +} diff --git a/src/it/unimi/dsi/test/MutableStringReplaceSpeedTest.java b/src/it/unimi/dsi/test/MutableStringReplaceSpeedTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f797c0873f18ca35fcc2a5dc3bf659b19730eae7 --- /dev/null +++ b/src/it/unimi/dsi/test/MutableStringReplaceSpeedTest.java @@ -0,0 +1,94 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import it.unimi.dsi.lang.MutableString; + +public class MutableStringReplaceSpeedTest { + + private MutableStringReplaceSpeedTest() {} + + public static void main(final String[] arg) throws IOException { + + String target = null; + + final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + final MutableString ms = new MutableString(); + String line; + while ((line = br.readLine()) != null) ms.append("\n").append(line); + target = ms.toString(); + + MutableString s; + String st; + final String searchString = arg[0]; + if (searchString.length() != 1) throw new IllegalArgumentException(); + final char searchChar = new MutableString(arg[0]).charAt(0); + final String replaceString = arg[1]; + final MutableString replace = new MutableString(replaceString); + final int n = Integer.parseInt(arg[2]); + long start; + + for (int k = 10; k-- != 0;) { + System.out.println(); + + s = new MutableString(target).compact(); + start = -System.nanoTime(); + for(int i = n; i-- != 0;) s.replace(searchChar, replace); + start += System.nanoTime(); + System.out.println("Called replace() " + n + " times on a compact string in " + start + " ns (" + start / (double)n + " ns/call)"); + + s = new MutableString(target).loose(); + start = -System.nanoTime(); + for(int i = n; i-- != 0;) s.replace(searchChar, replace); + start += System.nanoTime(); + System.out.println("Called replace() " + n + " times on a loose string in " + start + " ns (" + start / (double)n + " ns/call)"); + + final StringBuilder sb = new StringBuilder(target); + start = -System.nanoTime(); + + for(int i = n; i-- != 0;) { + int j = sb.length(); + for (;;) { + j = sb.lastIndexOf(searchString, j); + if (j == -1) break; + sb.replace(j, j + 1, replaceString); + j--; + } + } + + start += System.nanoTime(); + System.out.println("Called replace() " + n + " times on a string builder in " + start + " ns (" + start / (double)n + " ns/call)"); + assert sb.length() == s.length(); + assert s.toString().equals(sb.toString()); + + st = new String(target); + start = -System.nanoTime(); + for(int i = n; i-- != 0;) st = st.replaceAll(searchString, replaceString); + start += System.nanoTime(); + System.out.println("Called replaceAll() " + n + " times on a string in " + start + " ns (" + start / (double)n + " ns/call)"); + assert sb.length() == st.length(); + assert st.equals(sb.toString()); + } + } +} diff --git a/src/it/unimi/dsi/test/RandomSpeed.java b/src/it/unimi/dsi/test/RandomSpeed.java new file mode 100644 index 0000000000000000000000000000000000000000..29df475ceeead8b4de5a16cb95f987bede301f47 --- /dev/null +++ b/src/it/unimi/dsi/test/RandomSpeed.java @@ -0,0 +1,771 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.util.SplittableRandom; +import java.util.concurrent.ThreadLocalRandom; + +import it.unimi.dsi.logging.ProgressLogger; +import it.unimi.dsi.util.SplitMix64RandomGenerator; +import it.unimi.dsi.util.XoRoShiRo128PlusPlusRandomGenerator; +import it.unimi.dsi.util.XoRoShiRo128StarStarRandomGenerator; +import it.unimi.dsi.util.XoShiRo256PlusPlusRandomGenerator; +import it.unimi.dsi.util.XoShiRo256StarStarRandomGenerator; + +@SuppressWarnings({ "unused" }) +public class RandomSpeed { + + private static long testNextInt(final ThreadLocalRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("ThreadLocalRandom.nextInt()..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(); + pl.done(n); + return x; + } + + private static long testNextInt(final SplitMix64RandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplitMixRandomGenerator.nextInt()..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(); + pl.done(n); + return x; + } + + private static long testNextInt(final SplittableRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplittableRandom.nextInt()..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(); + pl.done(n); + return x; + } + + private static long testNextInt(final XoShiRo256StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256StarStarRandomGenerator.nextInt()..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(); + pl.done(n); + return x; + } + + private static long testNextInt(final XoShiRo256PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256PlusPlusRandomGenerator.nextInt()..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(); + pl.done(n); + return x; + } + + private static long testNextInt(final XoRoShiRo128PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128PlusPlusRandomGenerator.nextInt()..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(); + pl.done(n); + return x; + } + + private static long testNextInt(final XoRoShiRo128StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128StarStarRandomGenerator.nextInt()..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(); + pl.done(n); + return x; + } + + private static long testNextLong(final ThreadLocalRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("ThreadLocalRandom.nextLong()..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(); + pl.done(n); + return x; + } + + private static long testNextLong(final SplitMix64RandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplitMixRandomGenerator.nextLong()..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(); + pl.done(n); + return x; + } + + private static long testNextLong(final SplittableRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplittableRandom.nextLong()..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(); + pl.done(n); + return x; + } + + private static long testNextLong(final XoShiRo256StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256StarStarRandomGenerator.nextLong()..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(); + pl.done(n); + return x; + } + + private static long testNextLong(final XoShiRo256PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256PlusPlusRandomGenerator.nextLong()..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(); + pl.done(n); + return x; + } + + private static long testNextLong(final XoRoShiRo128PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128PlusPlusRandomGenerator.nextLong()..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(); + pl.done(n); + return x; + } + + private static long testNextLong(final XoRoShiRo128StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128StarStarRandomGenerator.nextLong()..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(); + pl.done(n); + return x; + } + + private static long testNextDouble(final ThreadLocalRandom r, final long n, final ProgressLogger pl) { + double x = 0; + pl.start("ThreadLocalRandom.nextDouble()..."); + for (long i = n; i-- != 0;) + x = r.nextDouble(); + pl.done(n); + return (long) x; + } + + private static long testNextDouble(final SplitMix64RandomGenerator r, final long n, final ProgressLogger pl) { + double x = 0; + pl.start("SplitMixRandomGenerator.nextDouble()..."); + for (long i = n; i-- != 0;) + x = r.nextDouble(); + pl.done(n); + return (long) x; + } + + private static long testNextDouble(final SplittableRandom r, final long n, final ProgressLogger pl) { + double x = 0; + pl.start("SplittableRandom.nextDouble()..."); + for (long i = n; i-- != 0;) + x = r.nextDouble(); + pl.done(n); + return (long) x; + } + + private static long testNextDouble(final XoShiRo256StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + double x = 0; + pl.start("XoShiRo256StarStarRandomGenerator.nextDouble()..."); + for (long i = n; i-- != 0;) + x = r.nextDouble(); + pl.done(n); + return (long) x; + } + + private static long testNextDouble(final XoShiRo256PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + double x = 0; + pl.start("XoShiRo256PlusPlusRandomGenerator.nextDouble()..."); + for (long i = n; i-- != 0;) + x = r.nextDouble(); + pl.done(n); + return (long) x; + } + + private static long testNextDouble(final XoRoShiRo128PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + double x = 0; + pl.start("XoRoShiRo128PlusPlusRandomGenerator.nextDouble()..."); + for (long i = n; i-- != 0;) + x = r.nextDouble(); + pl.done(n); + return (long) x; + } + + private static long testNextDouble(final XoRoShiRo128StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + double x = 0; + pl.start("XoRoShiRo128StarStarRandomGenerator.nextDouble()..."); + for (long i = n; i-- != 0;) + x = r.nextDouble(); + pl.done(n); + return (long) x; + } + + private static long testNextInt1000000(final ThreadLocalRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("ThreadLocalRandom.nextInt(1000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1000000); + pl.done(n); + return x; + } + + private static long testNextInt1000000(final SplitMix64RandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplitMixRandomGenerator.nextInt(1000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1000000); + pl.done(n); + return x; + } + + private static long testNextInt1000000(final SplittableRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplittableRandom.nextInt(1000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1000000); + pl.done(n); + return x; + } + + private static long testNextInt1000000(final XoShiRo256StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256StarStarRandomGenerator.nextInt(1000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1000000); + pl.done(n); + return x; + } + + private static long testNextInt1000000(final XoShiRo256PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256PlusPlusRandomGenerator.nextInt(1000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1000000); + pl.done(n); + return x; + } + + private static long testNextInt1000000(final XoRoShiRo128PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128PlusPlusRandomGenerator.nextInt(1000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1000000); + pl.done(n); + return x; + } + + private static long testNextInt1000000(final XoRoShiRo128StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128StarStarRandomGenerator.nextInt(1000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1000000); + pl.done(n); + return x; + } + + private static long testNextInt229228(final ThreadLocalRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("ThreadLocalRandom.nextInt(2^29+2^28)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 29) + (1 << 28)); + pl.done(n); + return x; + } + + private static long testNextInt229228(final SplitMix64RandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplitMixRandomGenerator.nextInt(2^29+2^28)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 29) + (1 << 28)); + pl.done(n); + return x; + } + + private static long testNextInt229228(final SplittableRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplittableRandom.nextInt(2^29+2^28)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 29) + (1 << 28)); + pl.done(n); + return x; + } + + private static long testNextInt229228(final XoShiRo256StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256StarStarRandomGenerator.nextInt(2^29+2^28)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 29) + (1 << 28)); + pl.done(n); + return x; + } + + private static long testNextInt229228(final XoShiRo256PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256PlusPlusRandomGenerator.nextInt(2^29+2^28)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 29) + (1 << 28)); + pl.done(n); + return x; + } + + private static long testNextInt229228(final XoRoShiRo128PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128PlusPlusRandomGenerator.nextInt(2^29+2^28)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 29) + (1 << 28)); + pl.done(n); + return x; + } + + private static long testNextInt229228(final XoRoShiRo128StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128StarStarRandomGenerator.nextInt(2^29+2^28)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 29) + (1 << 28)); + pl.done(n); + return x; + } + + private static long testNextInt230(final ThreadLocalRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("ThreadLocalRandom.nextInt(2^30)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1 << 30); + pl.done(n); + return x; + } + + private static long testNextInt230(final SplitMix64RandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplitMixRandomGenerator.nextInt(2^30)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1 << 30); + pl.done(n); + return x; + } + + private static long testNextInt230(final SplittableRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplittableRandom.nextInt(2^30)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1 << 30); + pl.done(n); + return x; + } + + private static long testNextInt230(final XoShiRo256StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256StarStarRandomGenerator.nextInt(2^30)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1 << 30); + pl.done(n); + return x; + } + + private static long testNextInt230(final XoShiRo256PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256PlusPlusRandomGenerator.nextInt(2^30)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1 << 30); + pl.done(n); + return x; + } + + private static long testNextInt230(final XoRoShiRo128PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128PlusPlusRandomGenerator.nextInt(2^30)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1 << 30); + pl.done(n); + return x; + } + + private static long testNextInt230(final XoRoShiRo128StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128StarStarRandomGenerator.nextInt(2^30)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt(1 << 30); + pl.done(n); + return x; + } + + private static long testNextInt2301(final ThreadLocalRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("ThreadLocalRandom.nextInt(2^30+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + 1); + pl.done(n); + return x; + } + + private static long testNextInt2301(final SplitMix64RandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplitMixRandomGenerator.nextInt(2^30+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + 1); + pl.done(n); + return x; + } + + private static long testNextInt2301(final SplittableRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplittableRandom.nextInt(2^30+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + 1); + pl.done(n); + return x; + } + + private static long testNextInt2301(final XoShiRo256StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256StarStarRandomGenerator.nextInt(2^30+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + 1); + pl.done(n); + return x; + } + + private static long testNextInt2301(final XoShiRo256PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256PlusPlusRandomGenerator.nextInt(2^30+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + 1); + pl.done(n); + return x; + } + + private static long testNextInt2301(final XoRoShiRo128PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128PlusPlusRandomGenerator.nextInt(2^30+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + 1); + pl.done(n); + return x; + } + + private static long testNextInt2301(final XoRoShiRo128StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128StarStarRandomGenerator.nextInt(2^30+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + 1); + pl.done(n); + return x; + } + + private static long testNextInt230229(final ThreadLocalRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("ThreadLocalRandom.nextInt(2^30+2^29)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + (1 << 29)); + pl.done(n); + return x; + } + + private static long testNextInt230229(final SplitMix64RandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplitMixRandomGenerator.nextInt(2^30+2^29)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + (1 << 29)); + pl.done(n); + return x; + } + + private static long testNextInt230229(final SplittableRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplittableRandom.nextInt(2^30+2^29)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + (1 << 29)); + pl.done(n); + return x; + } + + private static long testNextInt230229(final XoShiRo256StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256StarStarRandomGenerator.nextInt(2^30+2^29)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + (1 << 29)); + pl.done(n); + return x; + } + + private static long testNextInt230229(final XoShiRo256PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256PlusPlusRandomGenerator.nextInt(2^30+2^29)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + (1 << 29)); + pl.done(n); + return x; + } + + private static long testNextInt230229(final XoRoShiRo128PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128PlusPlusRandomGenerator.nextInt(2^30+2^29)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + (1 << 29)); + pl.done(n); + return x; + } + + private static long testNextInt230229(final XoRoShiRo128StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128StarStarRandomGenerator.nextInt(2^30+2^29)..."); + for (long i = n; i-- != 0;) + x ^= r.nextInt((1 << 30) + (1 << 29)); + pl.done(n); + return x; + } + + private static long testNextLong1000000000000(final ThreadLocalRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("ThreadLocalRandom.nextLong(1000000000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(1000000000000L); + pl.done(n); + return x; + } + + private static long testNextLong1000000000000(final SplitMix64RandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplitMixRandomGenerator.nextLong(1000000000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(1000000000000L); + pl.done(n); + return x; + } + + private static long testNextLong1000000000000(final SplittableRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplittableRandom.nextLong(1000000000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(1000000000000L); + pl.done(n); + return x; + } + + private static long testNextLong1000000000000(final XoShiRo256StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256StarStarRandomGenerator.nextLong(1000000000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(1000000000000L); + pl.done(n); + return x; + } + + private static long testNextLong1000000000000(final XoShiRo256PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256PlusPlusRandomGenerator.nextLong(1000000000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(1000000000000L); + pl.done(n); + return x; + } + + private static long testNextLong1000000000000(final XoRoShiRo128PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128PlusPlusRandomGenerator.nextLong(1000000000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(1000000000000L); + pl.done(n); + return x; + } + + private static long testNextLong1000000000000(final XoRoShiRo128StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128StarStarRandomGenerator.nextLong(1000000000000)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(1000000000000L); + pl.done(n); + return x; + } + + private static long testNextLong2621(final ThreadLocalRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("ThreadLocalRandom.nextLong(2^62+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(4611686018427387905L); + pl.done(n); + return x; + } + + private static long testNextLong2621(final SplitMix64RandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplitMixRandomGenerator.nextLong(2^62+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(4611686018427387905L); + pl.done(n); + return x; + } + + private static long testNextLong2621(final SplittableRandom r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("SplittableRandom.nextLong(2^62+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(4611686018427387905L); + pl.done(n); + return x; + } + + private static long testNextLong2621(final XoShiRo256StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256StarStarRandomGenerator.nextLong(2^62+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(4611686018427387905L); + pl.done(n); + return x; + } + + private static long testNextLong2621(final XoShiRo256PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoShiRo256PlusPlusRandomGenerator.nextLong(2^62+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(4611686018427387905L); + pl.done(n); + return x; + } + + private static long testNextLong2621(final XoRoShiRo128PlusPlusRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128PlusPlusRandomGenerator.nextLong(2^62+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(4611686018427387905L); + pl.done(n); + return x; + } + + private static long testNextLong2621(final XoRoShiRo128StarStarRandomGenerator r, final long n, final ProgressLogger pl) { + long x = 0; + pl.start("XoRoShiRo128StarStarRandomGenerator.nextLong(2^62+1)..."); + for (long i = n; i-- != 0;) + x ^= r.nextLong(4611686018427387905L); + pl.done(n); + return x; + } + + public static void main(final String arg[]) { + final ProgressLogger pl = new ProgressLogger(); + final ThreadLocalRandom threadLocal = ThreadLocalRandom.current(); + final SplittableRandom splittable = new SplittableRandom(1); + final SplitMix64RandomGenerator splitMix = new SplitMix64RandomGenerator(1); + final XoRoShiRo128PlusPlusRandomGenerator xoroshiro128plusplus = new XoRoShiRo128PlusPlusRandomGenerator(1); + final XoShiRo256PlusPlusRandomGenerator xoshiro256plusplus = new XoShiRo256PlusPlusRandomGenerator(1); + final XoRoShiRo128StarStarRandomGenerator xoroshiro128starstar = new XoRoShiRo128StarStarRandomGenerator(1); + final XoShiRo256StarStarRandomGenerator xoshiro256starstar = new XoShiRo256StarStarRandomGenerator(1); + final long n = Long.parseLong(arg[0]); + long x = 0; + + for (int k = 4; k-- != 0;) { + x ^= testNextInt(threadLocal, n, pl); + x ^= testNextInt(splittable, n, pl); + x ^= testNextInt(splitMix, n, pl); + x ^= testNextInt(xoroshiro128plusplus, n, pl); + x ^= testNextInt(xoshiro256plusplus, n, pl); + x ^= testNextInt(xoroshiro128starstar, n, pl); + x ^= testNextInt(xoshiro256starstar, n, pl); + System.err.println(); + + x ^= testNextLong(threadLocal, n, pl); + x ^= testNextLong(splittable, n, pl); + x ^= testNextLong(splitMix, n, pl); + x ^= testNextLong(xoroshiro128plusplus, n, pl); + x ^= testNextLong(xoshiro256plusplus, n, pl); + x ^= testNextLong(xoroshiro128starstar, n, pl); + x ^= testNextLong(xoshiro256starstar, n, pl); + System.err.println(); + + x ^= testNextDouble(threadLocal, n, pl); + x ^= testNextDouble(splittable, n, pl); + x ^= testNextDouble(splitMix, n, pl); + x ^= testNextDouble(xoroshiro128plusplus, n, pl); + x ^= testNextDouble(xoshiro256plusplus, n, pl); + x ^= testNextDouble(xoroshiro128starstar, n, pl); + x ^= testNextDouble(xoshiro256starstar, n, pl); + System.err.println(); + + x ^= testNextInt1000000(threadLocal, n, pl); + x ^= testNextInt1000000(splittable, n, pl); + x ^= testNextInt1000000(splitMix, n, pl); + x ^= testNextInt1000000(xoroshiro128plusplus, n, pl); + x ^= testNextInt1000000(xoshiro256plusplus, n, pl); + x ^= testNextInt1000000(xoroshiro128starstar, n, pl); + x ^= testNextInt1000000(xoshiro256starstar, n, pl); + System.err.println(); + + x ^= testNextInt229228(threadLocal, n, pl); + x ^= testNextInt229228(splittable, n, pl); + x ^= testNextInt229228(splitMix, n, pl); + x ^= testNextInt229228(xoroshiro128plusplus, n, pl); + x ^= testNextInt229228(xoshiro256plusplus, n, pl); + x ^= testNextInt229228(xoroshiro128starstar, n, pl); + x ^= testNextInt229228(xoshiro256starstar, n, pl); + System.err.println(); + + x ^= testNextInt230(threadLocal, n, pl); + x ^= testNextInt230(splittable, n, pl); + x ^= testNextInt230(splitMix, n, pl); + x ^= testNextInt230(xoroshiro128plusplus, n, pl); + x ^= testNextInt230(xoshiro256plusplus, n, pl); + x ^= testNextInt230(xoroshiro128starstar, n, pl); + x ^= testNextInt230(xoshiro256starstar, n, pl); + System.err.println(); + + x ^= testNextInt2301(threadLocal, n, pl); + x ^= testNextInt2301(splittable, n, pl); + x ^= testNextInt2301(splitMix, n, pl); + x ^= testNextInt2301(xoroshiro128plusplus, n, pl); + x ^= testNextInt2301(xoshiro256plusplus, n, pl); + x ^= testNextInt2301(xoroshiro128starstar, n, pl); + x ^= testNextInt2301(xoshiro256starstar, n, pl); + System.err.println(); + + x ^= testNextInt230229(threadLocal, n, pl); + x ^= testNextInt230229(splittable, n, pl); + x ^= testNextInt230229(splitMix, n, pl); + x ^= testNextInt230229(xoroshiro128plusplus, n, pl); + x ^= testNextInt230229(xoshiro256plusplus, n, pl); + x ^= testNextInt230229(xoroshiro128starstar, n, pl); + x ^= testNextInt230229(xoshiro256starstar, n, pl); + System.err.println(); + + x ^= testNextLong1000000000000(threadLocal, n, pl); + x ^= testNextLong1000000000000(splittable, n, pl); + x ^= testNextLong1000000000000(splitMix, n, pl); + x ^= testNextLong1000000000000(xoroshiro128plusplus, n, pl); + x ^= testNextLong1000000000000(xoshiro256plusplus, n, pl); + x ^= testNextLong1000000000000(xoroshiro128starstar, n, pl); + x ^= testNextLong1000000000000(xoshiro256starstar, n, pl); + System.err.println(); + + x ^= testNextLong2621(threadLocal, n, pl); + x ^= testNextLong2621(splittable, n, pl); + x ^= testNextLong2621(splitMix, n, pl); + x ^= testNextLong2621(xoroshiro128plusplus, n, pl); + x ^= testNextLong2621(xoshiro256plusplus, n, pl); + x ^= testNextLong2621(xoroshiro128starstar, n, pl); + x ^= testNextLong2621(xoshiro256starstar, n, pl); + System.err.println(); + } + + if (x == 0) System.err.println('*'); + } +} diff --git a/src/it/unimi/dsi/test/StringMapSpeedTest.java b/src/it/unimi/dsi/test/StringMapSpeedTest.java new file mode 100644 index 0000000000000000000000000000000000000000..89f8717562e87167ce2956f680b1baa336b90ffb --- /dev/null +++ b/src/it/unimi/dsi/test/StringMapSpeedTest.java @@ -0,0 +1,161 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; + +import com.martiansoftware.jsap.FlaggedOption; +import com.martiansoftware.jsap.JSAP; +import com.martiansoftware.jsap.JSAPException; +import com.martiansoftware.jsap.JSAPResult; +import com.martiansoftware.jsap.Parameter; +import com.martiansoftware.jsap.SimpleJSAP; +import com.martiansoftware.jsap.Switch; +import com.martiansoftware.jsap.UnflaggedOption; +import com.martiansoftware.jsap.stringparsers.ForNameStringParser; + +import it.unimi.dsi.Util; +import it.unimi.dsi.fastutil.ints.IntArrays; +import it.unimi.dsi.fastutil.io.BinIO; +import it.unimi.dsi.fastutil.io.FastBufferedOutputStream; +import it.unimi.dsi.fastutil.objects.ObjectList; +import it.unimi.dsi.lang.MutableString; +import it.unimi.dsi.util.SplitMix64Random; +import it.unimi.dsi.util.StringMap; + +public class StringMapSpeedTest { + + @SuppressWarnings("deprecation") + public static void main(final String[] arg) throws NoSuchMethodException, IOException, JSAPException, ClassNotFoundException { + + final SimpleJSAP jsap = new SimpleJSAP(StringMapSpeedTest.class.getName(), "Test the speed of a string map", + new Parameter[] { + new FlaggedOption("bufferSize", JSAP.INTSIZE_PARSER, "64Ki", JSAP.NOT_REQUIRED, 'b', "buffer-size", "The size of the I/O buffer used to read terms."), + new FlaggedOption("n", JSAP.INTSIZE_PARSER, "1000000", JSAP.NOT_REQUIRED, 'n', "number-of-strings", "The (maximum) number of strings used for random testing."), + new FlaggedOption("encoding", ForNameStringParser.getParser(Charset.class), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term file encoding."), + new FlaggedOption("save", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 's', "save", "In case of random test, save to this file the strings used."), + new Switch("zipped", 'z', "zipped", "The term list is compressed in gzip format."), + new Switch("random", 'r', "random", "Do a random test on at most 1 million strings."), + new Switch("check", 'c', "check", "Check that the term list is mapped to its ordinal position."), + new UnflaggedOption("function", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised function."), + new UnflaggedOption("termFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "Read terms from this file."), + }); + + final JSAPResult jsapResult = jsap.parse(arg); + if (jsap.messagePrinted()) return; + + final String functionName = jsapResult.getString("function"); + final String termFile = jsapResult.getString("termFile"); + final Charset encoding = (Charset)jsapResult.getObject("encoding"); + final boolean zipped = jsapResult.getBoolean("zipped"); + final boolean check = jsapResult.getBoolean("check"); + final boolean random = jsapResult.getBoolean("random"); + final String save = jsapResult.getString("save"); + final int maxStrings = jsapResult.getInt("n"); + + if (save != null && ! random) throw new IllegalArgumentException("You can save test string only for random tests"); + + @SuppressWarnings("unchecked") + final StringMap<? extends CharSequence> function = (StringMap<? extends CharSequence>)BinIO.loadObject(functionName); + final it.unimi.dsi.io.FileLinesCollection flc = new it.unimi.dsi.io.FileLinesCollection(termFile, encoding.name(), zipped); + + if (random) { + final ObjectList<MutableString> fll = new it.unimi.dsi.io.FileLinesCollection(termFile, encoding.name()).allLines(); + final int size = fll.size(); + final int n = Math.min(maxStrings, size); + final MutableString[] test = new MutableString[n]; + final int step = size / n; + for(int i = 0; i < n; i++) test[i] = fll.get(i * step); + Collections.shuffle(Arrays.asList(test)); + + if (save != null) { + final PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FastBufferedOutputStream(new FileOutputStream(save)), encoding)); + for(final MutableString s: test) s.println(pw); + pw.close(); + } + + System.out.println("== From string to integer =="); + + long total = 0; + for(int k = 13; k-- != 0;) { + long time = -System.nanoTime(); + for(int i = 0; i < n; i++) { + function.getLong(test[i]); + if (i % 100000 == 0) System.out.print('.'); + } + System.out.println(); + time += System.nanoTime(); + if (k < 10) total += time; + System.out.println(time / 1E9 + "s, " + time / n + " ns/item"); + } + System.out.println("Average: " + Util.format(total / 1E9) + "s, " + Util.format(total / (10 * n)) + " ns/item"); + + System.out.println("== From integer to string =="); + + total = 0; + final ObjectList<?> list = function.list(); + final int[] index = new int[n]; + for(int i = n - 1; i-- != 0;) index[i] = index[i + 1] + step; + IntArrays.shuffle(index, new SplitMix64Random()); + + for(int k = 13; k-- != 0;) { + long time = -System.nanoTime(); + for(int i = 0; i < n; i++) { + list.get(index[i]); + if (i % 100000 == 0) System.out.print('.'); + } + System.out.println(); + time += System.nanoTime(); + if (k < 10) total += time; + System.out.println(Util.format(time / 1E9) + "s, " + Util.format((double)time / n) + " ns/item"); + } + System.out.println("Average: " + Util.format(total / 10E9) + "s, " + Util.format(total / (10 * n)) + " ns/item"); + } + else { + int size = 0; + long total = 0; + for(int k = 13; k-- != 0;) { + final Iterator<? extends CharSequence> i = flc.iterator(); + + long time = -System.nanoTime(); + int j = 0; + long index; + while(i.hasNext()) { + index = function.getLong(i.next()); + if (check && index != j) throw new AssertionError(index + " != " + j); + if (j++ % 10000 == 0) System.err.print('.'); + } + size = j; + System.err.println(); + time += System.nanoTime(); + if (k < 10) total += time; + System.err.println(Util.format(total / 1E9) + "s, " + Util.format((total / 1E9) / j) + " ns/item"); + } + System.out.println("Average: " + Util.format(total / 10E9) + "s, " + Util.format(total / (10 * size)) + " ns/item"); + } + } +} diff --git a/src/it/unimi/dsi/test/TextPatternSpeedTest.java b/src/it/unimi/dsi/test/TextPatternSpeedTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0d37f0b4869321e8ff0b894779bd59014b14a7ac --- /dev/null +++ b/src/it/unimi/dsi/test/TextPatternSpeedTest.java @@ -0,0 +1,112 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import it.unimi.dsi.Util; +import it.unimi.dsi.lang.MutableString; +import it.unimi.dsi.util.TextPattern; + +public class TextPatternSpeedTest { + + private TextPatternSpeedTest() {} + + public static void main(final String[] arg) { + + String target = null; + final MutableString ms = new MutableString(); + + try { + final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + String line; + while ((line = br.readLine()) != null) ms.append("\n").append(line); + ms.compact(); + target = ms.toString(); + } catch (final IOException e) { + System.out.println("Problems while reading target"); + e.printStackTrace(System.out); + System.exit(1); + } + + int i, n; + + final String p = arg[0]; + + int k; + long start; + System.out.println("Searching for " + arg[0]); + + for(k = 10; k-- != 0;) { + System.out.println(); + + start = - System.nanoTime(); + n = 0; + + for(int r = 100; r-- != 0;) { + i = -1; + do { + i = target.indexOf(p, i + 1); + n++; + } while(i != -1); + + } + + start += System.nanoTime(); + + System.out.println("Called indexOf() " + n + " times on a string in " + start + " ns (" + Util.format(start / (double)n) + " ns/call)"); + final TextPattern tp = new TextPattern(p); + final char a[] = ms.array(); + + start = - System.nanoTime(); + n = 0; + + for(int r = 100; r-- != 0;) { + i = -1; + do { + i = tp.search(a, i + 1); + n++; + } while(i != -1); + } + + start += System.nanoTime(); + + System.out.println("Called search() " + n + " times on a string in " + start + " ns (" + Util.format(start / (double)n) + " ns/call)"); + + final MutableString pattern = new MutableString(p); + start = - System.nanoTime(); + n = 0; + + for(int r = 100; r-- != 0;) { + i = -1; + do { + i = ms.indexOf(pattern, i + 1); + n++; + } while(i != -1); + } + + start += System.nanoTime(); + + System.out.println("Called indexOf() " + n + " times on a mutable string in " + start + " ns (" + Util.format(start / (double)n) + " ns/call)"); + } + } +} diff --git a/src/it/unimi/dsi/test/WTF.java b/src/it/unimi/dsi/test/WTF.java new file mode 100644 index 0000000000000000000000000000000000000000..287e858cc93c291f17c7e367958a6d3e74692ef1 --- /dev/null +++ b/src/it/unimi/dsi/test/WTF.java @@ -0,0 +1,34 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.util.Random; + +public class WTF { + /* From https://twitter.com/joshbloch/status/269478731238760448 + * + * Note that ThreadLocalRandom uses the same algorithm as Random. + */ + public static void main(final String[] arg) { + final int shift = arg.length == 0 ? 0 : Integer.parseInt(arg[0]); + for (int i = 0; i < 1000; i++) + System.out.println(new Random(i).nextInt(1 << shift)); + } +} diff --git a/src/it/unimi/dsi/test/XorShift.java b/src/it/unimi/dsi/test/XorShift.java new file mode 100644 index 0000000000000000000000000000000000000000..ddea34a09ee8039b9b5479df9c6d435eca83bb6e --- /dev/null +++ b/src/it/unimi/dsi/test/XorShift.java @@ -0,0 +1,363 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.math.BigInteger; +import java.util.Arrays; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class XorShift { + + private XorShift() {} + + /** The number of bits of state of the generator. */ + public static final int BITS = 4096; + + /** The period of the generator (2<sup>{@link #BITS}</sup> − 1). */ + public static final BigInteger twoToBitsMinus1 = BigInteger.valueOf(2).pow(BITS).subtract(BigInteger.ONE); + + /** Factors of the Fermat “primes” up to the eleventh (2<sup>2048</sup> + 1). */ + public static final BigInteger[] factor = { + new BigInteger("3"), + new BigInteger("5"), + new BigInteger("17"), + new BigInteger("257"), + new BigInteger("65537"), + new BigInteger("641"), + new BigInteger("6700417"), + new BigInteger("274177"), + new BigInteger("67280421310721"), + new BigInteger("59649589127497217"), + new BigInteger("5704689200685129054721"), + new BigInteger("1238926361552897"), + new BigInteger("93461639715357977769163558199606896584051237541638188580280321"), + new BigInteger("2424833"), + new BigInteger("7455602825647884208337395736200454918783366342657"), + new BigInteger("741640062627530801524787141901937474059940781097519023905821316144415759504705008092818711693940737"), + new BigInteger("45592577"), + new BigInteger("6487031809"), + new BigInteger("4659775785220018543264560743076778192897"), + new BigInteger("130439874405488189727484768796509903946608530841611892186895295776832416251471863574140227977573104895898783928842923844831149032913798729088601617946094119449010595906710130531906171018354491609619193912488538116080712299672322806217820753127014424577"), + new BigInteger("319489"), + new BigInteger("974849"), + new BigInteger("167988556341760475137"), + new BigInteger("3560841906445833920513"), + new BigInteger("173462447179147555430258970864309778377421844723664084649347019061363579192879108857591038330408837177983810868451546421940712978306134189864280826014542758708589243873685563973118948869399158545506611147420216132557017260564139394366945793220968665108959685482705388072645828554151936401912464931182546092879815733057795573358504982279280090942872567591518912118622751714319229788100979251036035496917279912663527358783236647193154777091427745377038294584918917590325110939381322486044298573971650711059244462177542540706913047034664643603491382441723306598834177") + }; + + /** An array of cofactors. Entry 0 ≤ {@code i} < {@link #numCofactors} contains {@link #twoToBitsMinus1} divided by {@link #factor factor[i]}. Note that some + * entries can be {@code null} if {@link #BITS} is less then 4096. */ + public static final BigInteger[] cofactor = new BigInteger[factor.length]; + + /** The actual number of valid entries in {@link #cofactor}. */ + public static final int numCofactors; + + static { + BigInteger result = BigInteger.ONE; + int i; + // Initialize cofactors. + for(i = 0; i < factor.length; i++) { + cofactor[i] = twoToBitsMinus1.divide(factor[i]); + result = result.multiply(factor[i]); + if (twoToBitsMinus1.equals(result)) break; + } + + numCofactors = i + 1; + // Safety check (you know, those numbers are LONG). + if (! twoToBitsMinus1.equals(result)) throw new AssertionError(); + } + + /** Creates a bit matrix in compact representation: only the first and last 64 rows, and only the + * first 64 columns of the remaining rows are actually represented. The remaining entries are + * returned by {@link #word(long[][], int, int, int)} by extending the explicit values in a Toeplitz-like fashion. + * Each row is represented by an array of longs, each representing 64 bits. Bit in column {@code i} can + * be retrieved as {@code row[i / 64] & 1L << i}. + * + * @param bits the number of bits in a row. + * @return a new matrix as described above. + */ + public static long[][] newMatrix(final int bits) { + final long[][] result = new long[bits][]; + for(int i = 0; i < 64; i++) { + result[i] = new long[bits / 64]; + result[i + (bits - 64)] = new long[bits / 64]; + } + for(int i = 64; i < bits- 64; i++) result[i] = new long[1]; + + return result; + } + + /** Returns a specified word from a matrix in compact representation. + * + * @param matrix a matrix in compact form. + * @param r the row, starting from 0. + * @param cw the column index of a word, starting from 0. + * @param bits the number of bits in a row. + * @return the specified word. + * @see #newMatrix(int) + */ + public static long word(final long[][] matrix, final int r, final int cw, final int bits) { + if (r < 64 || r >= bits - 64) return matrix[r][cw]; + if (r - cw * 64 >= 0) return matrix[r - cw * 64][0]; + return matrix[r % 64][cw - r / 64]; + } + + /** Multiplies two 64x64 bit matrices represented as arrays of longs. + * + * @param x a 64x64 bit matrix. + * @param y a 64x64 bit matrix. + * @return the product of {@code x} and {@code y}. + */ + public static long[] multiply(final long[] x, final long[] y) { + final long[] u = new long[64]; + for(int i = 64; i-- != 0;) { + final long rx = x[i]; + long ra = 0; + for(int j = 64; j-- != 0;) if ((rx & 1L << j) != 0) ra ^= y[j]; + u[i] = ra; + } + return u; + } + + /** 64x64 bit matrices of the form I + R<sup><var>a</var></sup>. */ + public static long[][] right = new long[64][64]; + /** 64x64 bit matrices of the form I + L<sup><var>a</var></sup>. */ + public static long[][] left = new long[64][64]; + + static { + // Compute 64x64 powered shifts + for (int i = 0; i < 63; i++) right[1][i + 1] |= 1L << i; + for (int i = 0; i < 63; i++) left[1][i] |= 1L << (i + 1); + for (int i = 2; i < 64; i++) { + left[i] = multiply(left[i - 1], left[1]); + right[i] = multiply(right[i - 1], right[1]); + } + + // Add the identity + for (int i = 64; i-- != 0;) + for (int j = 64; j-- != 0;) { + right[i][j] |= 1L << j; + left[i][j] |= 1L << j; + } + + } + + /** Multiplies two matrices in compact representation. + * + * @param x a matrix in compact representation. + * @param y a matrix in compact representation. + * @return the product of {@code x} and {@code y} in compact representation. + * @see #newMatrix(int) + */ + public static long[][] multiply(final long[][] x, final long[][] y) { + final long[][] z = newMatrix(BITS); + + int r; + // First 64 rows must be computed fully. + for(r = 0; r < 64; r++) { + final long[] xr = x[r]; + final long[] zr = z[r]; + for(int cw = BITS / 64; cw-- != 0;) { + long t = xr[cw]; + final int offset = cw * 64 + 63; + for(int b = 64; b-- != 0;) { + if ((t & 1) != 0) for(int w = BITS / 64; w-- != 0;) zr[w] ^= word(y, offset - b, w, BITS); + t >>>= 1; + } + } + } + + // Next BITS - 128 rows need just computation of the first word. + for(; r < BITS - 64; r++) { + final long[] zr = z[r]; + for(int cw = BITS / 64; cw-- != 0;) { + long t = word(x, r, cw, BITS); + final int offset = cw * 64 + 63; + for(int b = 64; b-- != 0;) { + if ((t & 1) != 0) zr[0] ^= y[offset - b][0]; + t >>>= 1; + } + } + } + + // Last 64 rows must be computed fully. + for(; r < BITS; r++) { + final long[] xr = x[r]; + final long[] zr = z[r]; + for(int cw = BITS / 64; cw-- != 0;) { + long t = xr[cw]; + final int offset = cw * 64 + 63; + for(int b = 64; b-- != 0;) { + if ((t & 1) != 0) for(int w = BITS / 64; w-- != 0;) zr[w] ^= word(y, offset - b, w, BITS); + t >>>= 1; + } + } + } + + return z; + } + + /** Computes the quadratures of a matrix in compact represention. + * + * @param x a matrix in compact representation. + * @return an array of matrices in compact representation; the {@code i}-th + * entry of the matrix is <code>x<sup>2<sup>i</sup></sup></code> (0 ≤ {@code i} ≤ {@link #BITS}). + * @see #newMatrix(int) + */ + public static long[][][] quad(final long[][] x) { + final long[][][] result = new long[BITS + 1][][]; + result[0] = x; + //ProgressLogger progressLogger = new ProgressLogger(LOGGER, "quadratures"); + //progressLogger.expectedUpdates = 4095; + //progressLogger.displayLocalSpeed = true; + //progressLogger.start("Starting quadratures..."); + for(int i = 1; i <= BITS; i++) { + result[i] = multiply(result[i - 1], result[i - 1]); + //progressLogger.update(); + } + //progressLogger.done(); + return result; + } + + + /** Returns the identity matrix in compact representation. + * + * @return a compact representation of the identity. + * @see #newMatrix(int) + */ + public static long[][] identity() { + final long[][] m = newMatrix(BITS); + for(int i = 64; i-- != 0;) m[i][0] = 1L << i; + for(int i = 64; i-- != 0;) m[BITS - 64 + i][BITS / 64 - 1] = 1L << i; + return m; + } + + /** Checks whether a specified matrix in compact representation is the identity. + * + * @return true if {@code m} is the identity matrix. + * @see #newMatrix(int) + */ + public static boolean isIdentity(final long[][] m) { + for(int r = 64; r-- != 0;) if (m[r][0] != 1L << r) return false; + + for(int cw = 1; cw < BITS / 64; cw++) + for(int r = 64; r-- != 0;) if (m[r][cw] != 0) return false; + + for(int r = 64; r < BITS - 64; r++) if (m[r][0] != 0) return false; + + for(int r = 64; r-- != 0;) if (m[BITS - 64 + r][BITS / 64 - 1] != 1L << r) return false; + + for(int cw = 0; cw < BITS / 64 - 1; cw++) + for(int r = 64; r-- != 0;) if (m[BITS - 64 + r][cw] != 0) return false; + + return true; + } + + /** Computes the power of a matrix to a given exponent, given the quadratures of the matrix. + * + * @param q the quadratures of some matrix as returned by {@link #quad(long[][])}. + * @param e an exponent smaller than or equal to 2<sup>{@link #BITS}</sup>. + * @return the matrix whose array of quadratures is {@code q} raised to exponent {@code e}. + * @see #newMatrix(int) + */ + public static long[][] mPow(final long[][][] q, BigInteger e) { + long[][] r = identity(); + for(int i = 0; ! e.equals(BigInteger.ZERO); i++) { + if (e.testBit(0)) r = multiply(r, q[i]); + e = e.shiftRight(1); + } + return r; + } + + /** Checks whether a specified matrix in compact representation has full period. + * + * @param m a matrix in compact representation. + * @return true of {@code m} has full period (i.e., 2<sup>{@link #BITS}</sup> − 1). + * @see #newMatrix(int) + */ + public static boolean isFull(final long[][] m) { + final long[][][] q = quad(m); + if (! Arrays.deepEquals(m, q[BITS])) { + System.err.println("Does not give the identity"); + return false; + } + for(int i = 0; i < numCofactors; i++) { + if (isIdentity(mPow(q, cofactor[i]))){ + System.err.println("Gives the identity on cofactor " + cofactor[i]); + return false; + } + } + + return true; + } + + /** Creates a matrix in compact form representing a xorshift generator as suggested by Marsaglia + * in <a href="http://www.jstatsoft.org/v08/i14/paper/">“Xorshift RNGs”</a>, + * <i>Journal of Statistical Software</i>, 8:1−6, 2003. + * + * @param a the first shift parameter. + * @param b the second shift parameter. + * @param c the third shift parameter. + * @param bits the number of bits in a row. + * @return a matrix representing a xorshift generator with specified parameters and number of bits. + * @see #newMatrix(int) + */ + public static long[][] makeABCMatrix(final int a, final int b , final int c, final int bits) { + final long[][] m = XorShift.newMatrix(bits); + final long[] top = multiply(left[a], right[b]); + + for(int i = 64; i-- != 0;) m[i][bits / 64 - 1] = top[i]; + for(int i = 64; i-- != 0;) m[bits - 64 + i][bits / 64 - 1] = right[c][i]; + for(int i = 64; i-- != 0;) m[bits - 64 + i][bits / 64 - 2] = 1L << i; + for(int i = 64; i-- != 0;) m[64 + i][0] = 1L << i; + return m; + } + + public static final class Compute implements Runnable { + final int a, b, c; + + public Compute(final int a, final int b, final int c) { + this.a = a; + this.b = b; + this.c = c; + } + + @Override + public void run() { + final long[][] m = makeABCMatrix(a, b, c, BITS); + System.out.println(a + " " + b + " " + c + " " + isFull(m)); + } + } + + public static void main(final String arg[]) { + if (arg.length > 0) throw new IllegalArgumentException("This command takes no arguments (BITS=" + BITS + ")"); + final ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); + for(int a = 1; a < 64; a++) { + for(int b = 1; b <= 64 - a; b++) { + // Only pairs a+b<=64 such that a and b are coprime. + if (BigInteger.valueOf(a).gcd(BigInteger.valueOf(b)).intValue() != 1) continue; + for(int c = 1; c < 64; c++) exec.execute(new Compute(a, b, c)); + } + } + + exec.shutdown(); + } +} diff --git a/src/it/unimi/dsi/test/XorShiftPoly.java b/src/it/unimi/dsi/test/XorShiftPoly.java new file mode 100644 index 0000000000000000000000000000000000000000..6111bca1348044fbdc8bb4792fa2940befa35c67 --- /dev/null +++ b/src/it/unimi/dsi/test/XorShiftPoly.java @@ -0,0 +1,116 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + + +package it.unimi.dsi.test; + +import java.math.BigInteger; + +public class XorShiftPoly { + + private XorShiftPoly() {} + + /** The number of bits of state of the generator. */ + public static int bits; + + /** The period of the generator (2<sup>{@link #bits}</sup> − 1). */ + public static BigInteger twoToBitsMinus1; + + /** Factors of the Fermat “primes” up to the eleventh (2<sup>2048</sup> + 1). */ + public static final BigInteger[] factor = { + new BigInteger("3"), + new BigInteger("5"), + new BigInteger("17"), + new BigInteger("257"), + new BigInteger("65537"), + new BigInteger("641"), + new BigInteger("6700417"), + new BigInteger("274177"), + new BigInteger("67280421310721"), + new BigInteger("59649589127497217"), + new BigInteger("5704689200685129054721"), + new BigInteger("1238926361552897"), + new BigInteger("93461639715357977769163558199606896584051237541638188580280321"), + new BigInteger("2424833"), + new BigInteger("7455602825647884208337395736200454918783366342657"), + new BigInteger("741640062627530801524787141901937474059940781097519023905821316144415759504705008092818711693940737"), + new BigInteger("45592577"), + new BigInteger("6487031809"), + new BigInteger("4659775785220018543264560743076778192897"), + new BigInteger("130439874405488189727484768796509903946608530841611892186895295776832416251471863574140227977573104895898783928842923844831149032913798729088601617946094119449010595906710130531906171018354491609619193912488538116080712299672322806217820753127014424577"), + new BigInteger("319489"), + new BigInteger("974849"), + new BigInteger("167988556341760475137"), + new BigInteger("3560841906445833920513"), + new BigInteger("173462447179147555430258970864309778377421844723664084649347019061363579192879108857591038330408837177983810868451546421940712978306134189864280826014542758708589243873685563973118948869399158545506611147420216132557017260564139394366945793220968665108959685482705388072645828554151936401912464931182546092879815733057795573358504982279280090942872567591518912118622751714319229788100979251036035496917279912663527358783236647193154777091427745377038294584918917590325110939381322486044298573971650711059244462177542540706913047034664643603491382441723306598834177") + }; + + /** An array of cofactors. Entry 0 ≤ {@code i} < {@link #numCofactors} contains {@link #twoToBitsMinus1} divided by {@link #factor factor[i]}. Note that some + * entries can be {@code null} if {@link #bits} is less then 4096. */ + public static final BigInteger[] cofactor = new BigInteger[factor.length]; + + /** The actual number of valid entries in {@link #cofactor}. */ + public static int numCofactors; + + /** Computes the power to a given exponent, given the quadratures. + * + * @param e an exponent smaller than or equal to 2<sup>{@link #bits}</sup>. + */ + public static void mPow(BigInteger e) { + System.out.println("p := 1;"); + for(int i = 0; ! e.equals(BigInteger.ZERO); i++) { + if (e.testBit(0)) System.out.println("p := *p * q[" + i + "];"); + e = e.shiftRight(1); + } + } + + public static void main(final String arg[]) { + bits = Integer.parseInt(arg[0]); + + if (bits > 4096 || bits != Integer.highestOneBit(bits)) { + System.err.println("The number of bits must be a power of two smaller than or equal to 4096"); + System.exit(1); + } + + BigInteger result = BigInteger.ONE; + twoToBitsMinus1 = BigInteger.valueOf(2).pow(bits).subtract(BigInteger.ONE); + int n; + // Initialize cofactors. + for(n = 0; n < factor.length; n++) { + cofactor[n] = twoToBitsMinus1.divide(factor[n]); + result = result.multiply(factor[n]); + if (twoToBitsMinus1.equals(result)) break; + } + + numCofactors = n + 1; + // Safety check (you know, those numbers are LONG). + if (! twoToBitsMinus1.equals(result)) throw new AssertionError(); + + System.out.println("Array q[" + (bits + 1) + "];"); + // Quadratures + System.out.println("q[0] := x;"); + for(int i1 = 1; i1 <= bits; i1++) System.out.println("q[" + i1 + "] := q[" + (i1 - 1) + "] * q[" + (i1 - 1) + "];"); + System.out.println("!!('Check: ', if q[" + bits + "] = x then 1 else 0; &q fi);"); + // Exponentiation to cofactors + for(int i = 0; i < numCofactors; i++) { + mPow(cofactor[i]); + System.out.println("!!('Result: ', if p = 1 then 0; &q else 1 fi);"); + } + } +} diff --git a/src/it/unimi/dsi/test/XorShiftPoly116.java b/src/it/unimi/dsi/test/XorShiftPoly116.java new file mode 100644 index 0000000000000000000000000000000000000000..ec35af041c99d01ba9e72fb29ff7299f5e3d2cf4 --- /dev/null +++ b/src/it/unimi/dsi/test/XorShiftPoly116.java @@ -0,0 +1,98 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.math.BigInteger; + +public class XorShiftPoly116 { + + private XorShiftPoly116() {} + + /** The number of bits of state of the generator. */ + public static final int BITS = 116; + + /** The period of the generator (2<sup>{@value #BITS}</sup> − 1). */ + public static BigInteger twoToBitsMinus1; + + /** Factors of 2<sup>{@value #BITS}</sup> − - 1. */ + public static final BigInteger[] factor = { + new BigInteger("3"), + new BigInteger("5"), + new BigInteger("59"), + new BigInteger("233"), + new BigInteger("1103"), + new BigInteger("2089"), + new BigInteger("3033169"), + new BigInteger("107367629"), + new BigInteger("536903681") + }; + + /** An array of cofactors. Entry 0 ≤ {@code i} < {@link #numCofactors} contains {@link #twoToBitsMinus1} divided by {@link #factor factor[i]}. Note that some + * entries can be {@code null} if {@link #BITS} is less then 4096. */ + public static final BigInteger[] cofactor = new BigInteger[factor.length]; + + /** The actual number of valid entries in {@link #cofactor}. */ + public static int numCofactors; + + /** Computes the power to a given exponent, given the quadratures. + * + * @param e an exponent smaller than or equal to 2<sup>{@link #BITS}</sup>. + */ + public static void mPow(BigInteger e) { + System.out.println("p := 1;"); + for(int i = 0; ! e.equals(BigInteger.ZERO); i++) { + if (e.testBit(0)) System.out.println("p := *p * q[" + i + "];"); + e = e.shiftRight(1); + } + } + + public static void main(final String arg[]) { + // Check factors + BigInteger prod = BigInteger.ONE; + for(final BigInteger f : factor) prod = prod.multiply(f); + if (!prod.equals(BigInteger.valueOf(2).pow(BITS).subtract(BigInteger.ONE))) { + System.err.println("Factors do not match"); + return; + } + + BigInteger result = BigInteger.ONE; + twoToBitsMinus1 = BigInteger.valueOf(2).pow(BITS).subtract(BigInteger.ONE); + int n; + // Initialize cofactors. + for(n = 0; n < factor.length; n++) { + cofactor[n] = twoToBitsMinus1.divide(factor[n]); + result = result.multiply(factor[n]); + } + + // Safety check (you know, those numbers are LONG). + if (! twoToBitsMinus1.equals(result)) throw new AssertionError(); + + System.out.println("Array q[" + (BITS + 1) + "];"); + // Quadratures + System.out.println("q[0] := x;"); + for(int i1 = 1; i1 <= BITS; i1++) System.out.println("q[" + i1 + "] := q[" + (i1 - 1) + "] * q[" + (i1 - 1) + "];"); + System.out.println("!!('Check: ', if q[" + BITS + "] = x then 1 else 0; &q fi);"); + // Exponentiation to cofactors + for (final BigInteger element : cofactor) { + mPow(element); + System.out.println("!!('Result: ', if p = 1 then 0; &q else 1 fi);"); + } + } +} diff --git a/src/it/unimi/dsi/test/XorShiftPoly928.java b/src/it/unimi/dsi/test/XorShiftPoly928.java new file mode 100644 index 0000000000000000000000000000000000000000..46d4eef969107db71a31e6afa190121db406459b --- /dev/null +++ b/src/it/unimi/dsi/test/XorShiftPoly928.java @@ -0,0 +1,114 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import java.math.BigInteger; + +public class XorShiftPoly928 { + + private XorShiftPoly928() {} + + /** The number of bits of state of the generator. */ + public static final int BITS = 928; + + /** The period of the generator (2<sup>{@value #BITS}</sup> − 1). */ + public static BigInteger twoToBitsMinus1; + + /** Factors of 2<sup>{@value #BITS}</sup> − - 1. */ + public static final BigInteger[] factor = { + new BigInteger("3"), + new BigInteger("5"), + new BigInteger("17"), + new BigInteger("59"), + new BigInteger("233"), + new BigInteger("257"), + new BigInteger("929"), + new BigInteger("1103"), + new BigInteger("2089"), + new BigInteger("5569"), + new BigInteger("8353"), + new BigInteger("59393"), + new BigInteger("65537"), + new BigInteger("3033169"), + new BigInteger("39594977"), + new BigInteger("107367629"), + new BigInteger("536903681"), + new BigInteger("748264961"), + new BigInteger("2245984577"), + new BigInteger("239686663718401"), + new BigInteger("15929619591127520827829953"), + new BigInteger("82280195167144119832390568177"), + new BigInteger("6033312171721035031651315652130497"), + new BigInteger("18774318450142955120650303957350521748903233"), + new BigInteger("15694604006012505869851221169365594050637743819041") + }; + + /** An array of cofactors. Entry 0 ≤ {@code i} < {@link #numCofactors} contains {@link #twoToBitsMinus1} divided by {@link #factor factor[i]}. Note that some + * entries can be {@code null} if {@link #BITS} is less then 4096. */ + public static final BigInteger[] cofactor = new BigInteger[factor.length]; + + /** The actual number of valid entries in {@link #cofactor}. */ + public static int numCofactors; + + /** Computes the power to a given exponent, given the quadratures. + * + * @param e an exponent smaller than or equal to 2<sup>{@link #BITS}</sup>. + */ + public static void mPow(BigInteger e) { + System.out.println("p := 1;"); + for(int i = 0; ! e.equals(BigInteger.ZERO); i++) { + if (e.testBit(0)) System.out.println("p := *p * q[" + i + "];"); + e = e.shiftRight(1); + } + } + + public static void main(final String arg[]) { + // Check factors + BigInteger prod = BigInteger.ONE; + for(final BigInteger f : factor) prod = prod.multiply(f); + if (!prod.equals(BigInteger.valueOf(2).pow(BITS).subtract(BigInteger.ONE))) { + System.err.println("Factors do not match"); + return; + } + + BigInteger result = BigInteger.ONE; + twoToBitsMinus1 = BigInteger.valueOf(2).pow(BITS).subtract(BigInteger.ONE); + int n; + // Initialize cofactors. + for(n = 0; n < factor.length; n++) { + cofactor[n] = twoToBitsMinus1.divide(factor[n]); + result = result.multiply(factor[n]); + } + + // Safety check (you know, those numbers are LONG). + if (! twoToBitsMinus1.equals(result)) throw new AssertionError(); + + System.out.println("Array q[" + (BITS + 1) + "];"); + // Quadratures + System.out.println("q[0] := x;"); + for(int i1 = 1; i1 <= BITS; i1++) System.out.println("q[" + i1 + "] := q[" + (i1 - 1) + "] * q[" + (i1 - 1) + "];"); + System.out.println("!!('Check: ', if q[" + BITS + "] = x then 1 else 0; &q fi);"); + // Exponentiation to cofactors + for (final BigInteger element : cofactor) { + mPow(element); + System.out.println("!!('Result: ', if p = 1 then 0; &q else 1 fi);"); + } + } +} diff --git a/src/it/unimi/dsi/util/AbstractPrefixMap.java b/src/it/unimi/dsi/util/AbstractPrefixMap.java index 3a53229312b3ebf8f1415e603319b05da3434f56..3624381ed44d2653393f96bede8a0540c344e747 100644 --- a/src/it/unimi/dsi/util/AbstractPrefixMap.java +++ b/src/it/unimi/dsi/util/AbstractPrefixMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/BloomFilter.java b/src/it/unimi/dsi/util/BloomFilter.java index 9085ad72d312e7583b179a33f018da135ef95678..5bd26431dbaf9a71f0a79a9254e6dbc9a68d11b0 100644 --- a/src/it/unimi/dsi/util/BloomFilter.java +++ b/src/it/unimi/dsi/util/BloomFilter.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2004-2020 Sebastiano Vigna + * Copyright (C) 2004-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/ByteBufferLongBigList.java b/src/it/unimi/dsi/util/ByteBufferLongBigList.java index 3d2f3bf85f736ba5d62b7316585d1c4a08c42250..2013d31e48a569745bd55f3ebbe72a33511572f9 100644 --- a/src/it/unimi/dsi/util/ByteBufferLongBigList.java +++ b/src/it/unimi/dsi/util/ByteBufferLongBigList.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2012-2020 Sebastiano Vigna + * Copyright (C) 2012-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/CircularCharArrayBuffer.java b/src/it/unimi/dsi/util/CircularCharArrayBuffer.java index 3e99a001c0ee64e8120085748be429bc537efb6b..f9645fad47c8ad759734aadc926ae92f9b152aa4 100644 --- a/src/it/unimi/dsi/util/CircularCharArrayBuffer.java +++ b/src/it/unimi/dsi/util/CircularCharArrayBuffer.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2006-2020 Paolo Boldi + * Copyright (C) 2006-2021 Paolo Boldi * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/FrontCodedStringList.java b/src/it/unimi/dsi/util/FrontCodedStringList.java index 6a71a13924242ed00a81aa0d8dcf607c2a37e24f..e6ab5ae7b18526a670d92ab7329cb7f6561d5551 100644 --- a/src/it/unimi/dsi/util/FrontCodedStringList.java +++ b/src/it/unimi/dsi/util/FrontCodedStringList.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/HyperLogLogCounterArray.java b/src/it/unimi/dsi/util/HyperLogLogCounterArray.java index bf3be7ed2d805dab5e03603983d63c59f889cebd..c8d9b3c237d0dce15dcfc2d2d8ede023a0c1abcd 100644 --- a/src/it/unimi/dsi/util/HyperLogLogCounterArray.java +++ b/src/it/unimi/dsi/util/HyperLogLogCounterArray.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2010-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/ImmutableBinaryTrie.java b/src/it/unimi/dsi/util/ImmutableBinaryTrie.java index 4c414040c5c7116e8f3d4b2456b68219f6c41f04..cc1f90992de4c902ff4de6237e5d8d4ce0e28069 100644 --- a/src/it/unimi/dsi/util/ImmutableBinaryTrie.java +++ b/src/it/unimi/dsi/util/ImmutableBinaryTrie.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/ImmutableExternalPrefixMap.java b/src/it/unimi/dsi/util/ImmutableExternalPrefixMap.java index f3645727e7e9a44734d88aafd0d5922b4795ae8b..22abf0ad9c6aae1f96b86427db7665edd3fc1c34 100644 --- a/src/it/unimi/dsi/util/ImmutableExternalPrefixMap.java +++ b/src/it/unimi/dsi/util/ImmutableExternalPrefixMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; @@ -25,13 +24,12 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStreamReader; +import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.nio.charset.Charset; import java.util.Arrays; -import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; @@ -61,8 +59,7 @@ import it.unimi.dsi.fastutil.io.BinIO; import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectIterator; -import it.unimi.dsi.io.FastBufferedReader; -import it.unimi.dsi.io.FileLinesCollection; +import it.unimi.dsi.io.FileLinesMutableStringIterable; import it.unimi.dsi.io.InputBitStream; import it.unimi.dsi.io.OutputBitStream; import it.unimi.dsi.lang.MutableString; @@ -160,12 +157,16 @@ public class ImmutableExternalPrefixMap extends AbstractPrefixMap implements Ser /** A cache for the most recent queries */ protected transient Object2IntLinkedOpenHashMap<MutableString> cache; - /** Creates an external prefix map with specified block size and dump stream. + /** + * Creates an external prefix map with specified block size and dump stream. * - * <P>This constructor does not assume that {@link CharSequence} instances returned by <code>terms.iterator()</code> - * will be distinct. Thus, it can be safely used with {@link FileLinesCollection}. + * <P> + * This constructor does not assume that {@link CharSequence} instances returned by + * <code>terms.iterator()</code> will be distinct. Thus, it can be safely used with + * {@link FileLinesMutableStringIterable}. * - * @param terms an iterable whose iterator will enumerate in lexicographical order the terms for the map. + * @param terms an iterable whose iterator will enumerate in lexicographical order the terms for the + * map. * @param blockSizeInBytes the block size (in bytes). * @param dumpStreamFilename the name of the dump stream, or {@code null} for a self-contained map. */ @@ -323,12 +324,16 @@ public class ImmutableExternalPrefixMap extends AbstractPrefixMap implements Ser (this.cache = new Object2IntLinkedOpenHashMap<>()).defaultReturnValue(-1); } - /** Creates an external prefix map with block size {@link #STD_BLOCK_SIZE} and specified dump stream. + /** + * Creates an external prefix map with block size {@link #STD_BLOCK_SIZE} and specified dump stream. * - * <P>This constructor does not assume that {@link CharSequence} instances returned by <code>terms.iterator()</code> - * will be distinct. Thus, it can be safely used with {@link FileLinesCollection}. + * <P> + * This constructor does not assume that {@link CharSequence} instances returned by + * <code>terms.iterator()</code> will be distinct. Thus, it can be safely used with + * {@link FileLinesMutableStringIterable}. * - * @param terms a collection whose iterator will enumerate in lexicographical order the terms for the map. + * @param terms a collection whose iterator will enumerate in lexicographical order the terms for + * the map. * @param dumpStreamFilename the name of the dump stream, or {@code null} for a self-contained map. */ @@ -336,25 +341,33 @@ public class ImmutableExternalPrefixMap extends AbstractPrefixMap implements Ser this(terms, STD_BLOCK_SIZE, dumpStreamFilename); } - /** Creates an external prefix map with specified block size. + /** + * Creates an external prefix map with specified block size. * - * <P>This constructor does not assume that {@link CharSequence} instances returned by <code>terms.iterator()</code> - * will be distinct. Thus, it can be safely used with {@link FileLinesCollection}. + * <P> + * This constructor does not assume that {@link CharSequence} instances returned by + * <code>terms.iterator()</code> will be distinct. Thus, it can be safely used with + * {@link FileLinesMutableStringIterable}. * * @param blockSizeInBytes the block size (in bytes). - * @param terms a collection whose iterator will enumerate in lexicographical order the terms for the map. + * @param terms a collection whose iterator will enumerate in lexicographical order the terms for + * the map. */ public ImmutableExternalPrefixMap(final Iterable<? extends CharSequence> terms, final int blockSizeInBytes) throws IOException { this(terms, blockSizeInBytes, null); } - /** Creates an external prefix map with block size {@link #STD_BLOCK_SIZE}. + /** + * Creates an external prefix map with block size {@link #STD_BLOCK_SIZE}. * - * <P>This constructor does not assume that {@link CharSequence} instances returned by <code>terms.iterator()</code> - * will be distinct. Thus, it can be safely used with {@link FileLinesCollection}. + * <P> + * This constructor does not assume that {@link CharSequence} instances returned by + * <code>terms.iterator()</code> will be distinct. Thus, it can be safely used with + * {@link FileLinesMutableStringIterable}. * - * @param terms a collection whose iterator will enumerate in lexicographical order the terms for the map. + * @param terms a collection whose iterator will enumerate in lexicographical order the terms for + * the map. */ public ImmutableExternalPrefixMap(final Iterable<? extends CharSequence> terms) throws IOException { @@ -690,44 +703,40 @@ public class ImmutableExternalPrefixMap extends AbstractPrefixMap implements Ser @SuppressWarnings("unchecked") public static void main(final String[] arg) throws ClassNotFoundException, IOException, JSAPException, SecurityException, NoSuchMethodException { - final SimpleJSAP jsap = new SimpleJSAP(ImmutableExternalPrefixMap.class.getName(), - "Builds an external prefix map reading from standard input a newline-separated list of sorted terms or a serialised term list. If the dump stream name is not specified, the map will be self-contained.\n\n" + - "Note that if you read terms from stdin or from a serialized object all terms will have to be loaded in memory.", - new Parameter[] { - new FlaggedOption("blockSize", JSAP.INTSIZE_PARSER, (STD_BLOCK_SIZE / 1024) + "Ki", JSAP.NOT_REQUIRED, 'b', "block-size", "The size of a block in the dump stream."), - new Switch("serialised", 's', "serialised", "The data source (file or standard input) provides a serialised java.util.List of terms."), - new Switch("synchronised", 'S', "synchronised", "The serialised map will be synchronised."), - new Switch("zipped", 'z', "zipped", "Standard input is compressed in gzip format."), - new FlaggedOption("termFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "offline", "Read terms from this file instead of standard input."), - new FlaggedOption("encoding", ForNameStringParser.getParser(Charset.class), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term list encoding."), - new UnflaggedOption("map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised map."), - new UnflaggedOption("dump", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "An optional dump stream (the resulting map will not be self-contained).") - } - ); + final SimpleJSAP jsap = new SimpleJSAP(ImmutableExternalPrefixMap.class.getName(), "Builds an external prefix map reading from standard input a newline-separated list of sorted terms or a serialised term list. If the dump stream name is not specified, the map will be self-contained.\n\n" + "Note that if you read terms from stdin or from a serialized object all terms will have to be loaded in memory.", new Parameter[] { + new FlaggedOption("blockSize", JSAP.INTSIZE_PARSER, (STD_BLOCK_SIZE / 1024) + "Ki", JSAP.NOT_REQUIRED, 'b', "block-size", "The size of a block in the dump stream."), + new Switch("serialised", 's', "serialised", "The data source (file or standard input) provides a serialised java.util.List of terms."), + new Switch("synchronised", 'S', "synchronised", "The serialised map will be synchronised."), + new Switch("zipped", 'z', "zipped", "The term list is compressed in gzip format."), + new FlaggedOption("decompressor", JSAP.CLASS_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'd', "decompressor", "Use this extension of InputStream to decompress the terms."), + new FlaggedOption("termFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "offline", "Read terms from this file instead of standard input."), + new FlaggedOption("encoding", ForNameStringParser.getParser(Charset.class), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term list encoding."), + new UnflaggedOption("map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised map."), + new UnflaggedOption("dump", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "An optional dump stream (the resulting map will not be self-contained).") }); final JSAPResult jsapResult = jsap.parse(arg); if (jsap.messagePrinted()) return; - Collection<? extends CharSequence> termList; + Iterable<? extends CharSequence> termList; final String termFile = jsapResult.getString("termFile"); final Charset encoding = (Charset)jsapResult.getObject("encoding"); final boolean zipped = jsapResult.getBoolean("zipped"); + Class<? extends InputStream> decompressor = jsapResult.getClass("decompressor"); final boolean serialised = jsapResult.getBoolean("serialised"); final boolean synchronised = jsapResult.getBoolean("synchronised"); - if (zipped && serialised) throw new IllegalArgumentException("The zipped and serialised options are incompatible"); + if (zipped && decompressor != null) throw new IllegalArgumentException("The zipped and decompressor options are incompatible"); + if ((zipped || decompressor != null) && serialised) throw new IllegalArgumentException("The zipped/decompressor and serialised options are incompatible"); + + if (zipped) decompressor = GZIPInputStream.class; if (serialised) termList = (List<? extends CharSequence>) (termFile != null ? BinIO.loadObject(termFile) : BinIO.loadObject(System.in)); - else if (termFile != null) termList = new FileLinesCollection(termFile, encoding.name(), zipped); + else if (termFile != null) termList = new FileLinesMutableStringIterable(termFile, encoding, decompressor); else { - final ObjectArrayList<MutableString> list = new ObjectArrayList<>(); + final ObjectArrayList<String> list = new ObjectArrayList<>(); termList = list; - final FastBufferedReader terms = new FastBufferedReader(new InputStreamReader( - zipped ? new GZIPInputStream(System.in) : System.in, encoding.name())); - final MutableString term = new MutableString(); - while(terms.readLine(term) != null) list.add(term.copy()); - terms.close(); + FileLinesMutableStringIterable.iterator(System.in, encoding, decompressor).forEachRemaining(s -> list.add(s.toString())); } final ImmutableExternalPrefixMap immutableExternalPrefixMap = new ImmutableExternalPrefixMap(termList, jsapResult.getInt("blockSize"), jsapResult.getString("dump")); diff --git a/src/it/unimi/dsi/util/IntParallelCounterArray.java b/src/it/unimi/dsi/util/IntParallelCounterArray.java new file mode 100644 index 0000000000000000000000000000000000000000..e234bb1955814a93f46440557fc037d3e365ecce --- /dev/null +++ b/src/it/unimi/dsi/util/IntParallelCounterArray.java @@ -0,0 +1,333 @@ +/* + * DSI utilities + * + * Copyright (C) 2010-2021 Paolo Boldi and Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.util; + +import static it.unimi.dsi.bits.LongArrayBitVector.word; + +import java.io.Serializable; + +import it.unimi.dsi.Util; +import it.unimi.dsi.bits.Fast; +import it.unimi.dsi.bits.LongArrayBitVector; +import it.unimi.dsi.fastutil.longs.LongBigList; +import it.unimi.dsi.stat.Ziggurat; + +/** + * An array of approximate sets each represented using a Parallel counter. + * + * <p>Parallel counters represent the number of elements of a set in an approximate way. They have been + * introduced by Philippe Flajolet, Éric Fusy, Olivier Gandouet, and Freédeéric Meunier in + * “Parallel: the analysis of a near-optimal cardinality estimation algorithm”, + * <em>Proceedings of the 13th conference on analysis of algorithm (AofA 07)</em>, pages + * 127−146, 2007. They are an improvement over the basic idea of <em>loglog counting</em>, introduced by + * Marianne Durand and Philippe Flajolet in “Loglog counting of large cardinalities”, + * <i>ESA 2003, 11th Annual European Symposium</i>, volume 2832 of Lecture Notes in Computer Science, pages 605−617, Springer, 2003. + * + * <p>Each counter is composed by {@link #m} registers, and each register is made of {@link #registerSize} bits. + * The first number depends on the desired relative standard deviation, and its logarithm can be computed using {@link #log2NumberOfRegisters(double)}, + * whereas the second number depends on an upper bound on the number of distinct elements to be counted, and it can be computed + * using {@link #registerSize(long)}. + * + * <p>Actually, this class implements an <em>array</em> of counters. Each counter is completely independent, but they all use the same hash function. + * The reason for this design is that in our intended applications hundred of millions of counters are common, and the JVM overhead to create such a number of objects + * would be unbearable. This class allocates an array of {@link LongArrayBitVector}s, each containing {@link #CHUNK_SIZE} registers, + * and can thus handle billions of billions of registers efficiently (in turn, this means being able to + * handle an array of millions of billions of high-precision counters). + * + * <p>When creating an instance, you can choose the size of the array (i.e., the number of counters) and the desired relative standard deviation + * (either {@linkplain #IntParallelCounterArray(int, long, int, double) explicitly} or + * {@linkplain #IntParallelCounterArray(int, long, int, double) choosing the number of registers per counter}). + * Then, you can {@linkplain #add(int, int) add an element to a counter}. At any time, you can + * {@linkplain #count(int) count} count (approximately) the number of distinct elements that have been added to a counter. + * + * @author Paolo Boldi + * @author Sebastiano Vigna + */ + +public class IntParallelCounterArray implements Serializable { + private static final long serialVersionUID = 1L; + private static final boolean ASSERTS = false; + private static final boolean DEBUG = false; + + public static final int MAX_EXPONENT = 2; + + /** The logarithm of the maximum size in registers of a bit vector. */ + public static final int CHUNK_SHIFT = 30; + /** The maximum size in registers of a bit vector. */ + public static final long CHUNK_SIZE = 1L << CHUNK_SHIFT; + public static final long CHUNK_MASK = CHUNK_SIZE - 1; + + /** A an array of bit vectors containing all registers. */ + protected final LongArrayBitVector bitVector[]; + + /** {@link #registerSize}-bit views of {@link #bitVector}. */ + protected final LongBigList registers[]; + + /** The number of registers. */ + protected final int m; + + /** The number of registers. */ + protected final int log2m; + + /** The number of registers minus one. */ + protected final int mMinus1; + + /** The size in bits of each register. */ + protected final int registerSize; + + /** The mask corresponding to a register. */ + protected final int registerMask; + + /** The shift that selects the chunk corresponding to a node. */ + protected final int nodeShift; + + private final Ziggurat ziggurat; + protected double base; + private final double logBase; + private final int maxExponent; + + /** + * Returns the logarithm of the number of registers per counter that are necessary to attain a + * given relative standard deviation. + * + * @param rsd the relative standard deviation to be attained. + * @return the logarithm of the number of registers that are necessary to attain relative standard deviation <code>rsd</code>. + */ + public static int log2NumberOfRegisters(final double rsd) { + return (int)Math.ceil(Fast.log2((1 / rsd) * (1 / rsd))); + } + + + /** + * Returns the relative standard deviation corresponding to a given logarithm of the number of registers per counter. + * + * @param log2m the logarithm of the number of registers. + * @return the resulting relative standard deviation. + */ + public static double relativeStandardDeviation(final int log2m) { + return 1 / Math.sqrt(1 << log2m); + } + + /** + * Returns the register size in bits, given an upper bound on the number of distinct elements. + * + * @param n an upper bound on the number of distinct elements. + * @return the register size in bits. + */ + + public static int registerSize(final long n) { + return Math.max(4, (int)Math.ceil(Math.log(Math.log(n) / Math.log(2)) / Math.log(2))); + } + + /** + * Creates a new array of counters. + * + * @param arraySize the number of counters. + * @param n the expected number of elements. + * @param rsd the relative standard deviation. + * @param floatingPointPrecision the precision used for floating-point computations. + */ + public IntParallelCounterArray(final int arraySize, final long n, final double rsd, final double floatingPointPrecision) { + this(arraySize, n, log2NumberOfRegisters(rsd), floatingPointPrecision); + } + + /** + * Creates a new array of counters. + * + * @param arraySize the number of counters. + * @param n the expected number of elements. + * @param log2m the logarithm of the number of registers per counter. + * @param floatingPointPrecision the precision used for floating-point computations. + */ + public IntParallelCounterArray(final int arraySize, final long n, final int log2m, final double floatingPointPrecision) { + this(arraySize, n, log2m, floatingPointPrecision, Util.randomSeed()); + } + + /** + * Creates a new array of counters. + * + * @param arraySize the number of counters. + * @param n the expected number of elements. + * @param log2m the logarithm of the number of registers per counter. + * @param floatingPointPrecision the precision used for floating-point computations. + * @param seed the seed used to compute the hash function + */ + public IntParallelCounterArray(final int arraySize, final long n, final int log2m, final double floatingPointPrecision, final long seed) { + this.m = 1 << (this.log2m = log2m); + this.mMinus1 = m - 1; + this.registerSize = (int)(registerSize(n) + Math.ceil(-Fast.log2(floatingPointPrecision))); + registerMask = (1 << registerSize) - 1; + nodeShift = CHUNK_SHIFT - log2m; + + base = (1 + floatingPointPrecision) / (1 - floatingPointPrecision); + logBase = Math.log(base); + maxExponent = (int)Math.ceil(Math.log(2) / logBase); + + // System.err.println(arraySize + " " + m + " " + registerSize); + final long sizeInRegisters = (long)arraySize * m; + final int numVectors = (int)((sizeInRegisters + CHUNK_MASK) >>> CHUNK_SHIFT); + + bitVector = new LongArrayBitVector[numVectors]; + registers = new LongBigList[numVectors]; + for(int i = 0; i < numVectors; i++) { + this.bitVector[i] = LongArrayBitVector.ofLength(registerSize * Math.min(CHUNK_SIZE, sizeInRegisters - ((long)i << CHUNK_SHIFT))); + this.registers[i] = bitVector[i].asLongBigList(registerSize); + } + ziggurat = new Ziggurat(new XoRoShiRo128PlusRandom(seed)); + if (DEBUG) System.err.println("Register size: " + registerSize + " log2m (b): " + log2m + " m: " + m + " base: " + base); + } + + + private final double[] maxz = new double[10000]; + private final long[] maxe = new long[10000]; + + /** Adds an element to a counter. + * + * @param k the index of the counter. + * @param v the element to be added. + */ + public void add(final int k, final int v) { + final int registerSize = this.registerSize; + // Chunk of the first register + int chunk = (int)((long)k >>> nodeShift); + // Offset in bits of the first register inside the chunk + final long offset = ((long)k << log2m & CHUNK_MASK) * registerSize; + long[] bits = bitVector[chunk].bits(); + int length = bits.length; + + int word = word(offset) - 1; + long curr = 0; + // The number of bits still to be filled in curr. + // TODO: This won't work unless offset is a multiple of Long.SIZE. + int used = (int)(offset & ~-Long.SIZE); + + long ee[]; + + if (ASSERTS) ee = new long[m]; + + for (int i = 0; i < m; i++) { + final double z = ziggurat.nextDouble(); + maxz[i] = Math.max(maxz[i], 1/z); + final long e = Math.max(0, - Math.round(Math.log(z) / logBase) + maxExponent) & registerMask; + maxe[i] = Math.max(maxe[i], e); + //System.err.print(e + "\t"); + if (ASSERTS) ee[i] = e; + if (ASSERTS) assert e < (1 << registerSize); + if (ASSERTS) assert e >= 0; + + if (used < Long.SIZE - registerSize) { + curr |= e << used; + used += registerSize; + } + else { + if (++word == length) { + word = 0; + bits = bitVector[++chunk].bits(); + length = bits.length; + } + bits[word] = curr | e << used; + curr = e >>> -used; + used += registerSize - Long.SIZE; + } + } + + //System.err.println(); + + if (ASSERTS) { + for (int j = 0; j < m; j++) { + assert ee[j] == registers[(int)((((long)k << log2m) + j) >> CHUNK_SHIFT)].getLong((((long)k << log2m) + j) & CHUNK_MASK) : "[" + j + "] " + ee[j] + "!=" + registers[(int)((((long)k << log2m) + j) >> CHUNK_SHIFT)].getLong((((long)k << log2m) + j) & CHUNK_MASK); + } + } + + } + + public void printMins() { + for(int i = 0; i < m; i++) System.out.print(maxe[i] + "\t"); + System.err.println(); + for(int i = 0; i < m; i++) System.out.print(1 / maxz[i] + "\t"); + System.err.println(); + for(int i = 0; i < m; i++) System.out.print(maxz[i] + "\t"); + System.err.println(); + } + + + /** Returns the array of big lists of registers underlying this array of counters. + * + * <p>The main purpose of this method is debugging, as it makes comparing + * the evolution of the state of two implementations easy. + * + * @return the array of big lists of registers underlying this array of counters. + */ + + public LongBigList[] registers() { + return registers; + /* TODO: final LongBigList[] result = new LongBigList[registers.length]; + for(int i = result.length; i-- != 0;) result[i] = LongBigLists.unmodifiable(registers[i]); + return result;*/ + } + + /** Estimates the number of distinct elements that have been added to a given counter so far. + * + * @param k the index of the counter. + * @return an approximation of the number of distinct elements that have been added to counter <code>k</code> so far. + */ + public double count(final int k) { + double s = 0; + + final int registerSize = this.registerSize; + // Chunk of the first register + int chunk = (int)((long)k >>> nodeShift); + // Offset in bits of the first register inside the chunk + final long offset = ((long)k << log2m & CHUNK_MASK) * registerSize; + long[] bits = bitVector[chunk].bits(); + int length = bits.length; + + int word = word(offset); + long curr = bits[word] >>> offset; + long r; + int remaining = Long.SIZE - (int)(offset & ~-Long.SIZE); + final int mask = (1 << registerSize) - 1; + + for (int j = 0; j < m; j++) { + if (remaining >= registerSize) { + r = curr & mask; + curr >>>= registerSize; + remaining -= registerSize; + } + else { + if (++word == length) { + word = 0; + bits = bitVector[++chunk].bits(); + length = bits.length; + } + r = (curr | bits[word] << remaining) & mask; + curr = bits[word] >>> registerSize - remaining; + remaining += Long.SIZE - registerSize; + } + + if (ASSERTS) assert r == registers[(int)((((long)k << log2m) + j) >> CHUNK_SHIFT)].getLong((((long)k << log2m) + j) & CHUNK_MASK) : "[" + j + "] " + r + "!=" + registers[(int)((((long)k << log2m) + j) >> CHUNK_SHIFT)].getLong((((long)k << log2m) + j) & CHUNK_MASK); + + s += Math.pow(base, -r + maxExponent); + } + + return m / s; + } +} + diff --git a/src/it/unimi/dsi/util/Interval.java b/src/it/unimi/dsi/util/Interval.java index d3b97fcf7e9ec8eb029f58de7d616ef058981172..4ad0eeb3e2a78d0a934f77cd2a74d515471fef8a 100644 --- a/src/it/unimi/dsi/util/Interval.java +++ b/src/it/unimi/dsi/util/Interval.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2003-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2003-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/Intervals.java b/src/it/unimi/dsi/util/Intervals.java index aa8221b72138f8e5d0ebb013c54b08fd4cdfed9a..42af173d72862b16c88e5f39f7ad364da9206f6c 100644 --- a/src/it/unimi/dsi/util/Intervals.java +++ b/src/it/unimi/dsi/util/Intervals.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2003-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2003-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/KahanSummation.java b/src/it/unimi/dsi/util/KahanSummation.java index b8ee471a62e93bd391bd0a003b4102fdc5c90291..114318f57f93673296601905aa4222414026be8f 100644 --- a/src/it/unimi/dsi/util/KahanSummation.java +++ b/src/it/unimi/dsi/util/KahanSummation.java @@ -1,19 +1,20 @@ /* - * Copyright (C) 2011-2020 Sebastiano Vigna + * DSI utilities * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * Copyright (C) 2012-2021 Sebastiano Vigna * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/LiterallySignedStringMap.java b/src/it/unimi/dsi/util/LiterallySignedStringMap.java index 862daa51fcc631745747dfedb7ad58c9bd329825..1c478f5c364c669a6d750f87c93f961da771b2c3 100644 --- a/src/it/unimi/dsi/util/LiterallySignedStringMap.java +++ b/src/it/unimi/dsi/util/LiterallySignedStringMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2009-2020 Sebastiano Vigna + * Copyright (C) 2009-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; @@ -23,6 +22,7 @@ package it.unimi.dsi.util; import java.io.IOException; import java.io.Serializable; import java.nio.charset.Charset; +import java.util.zip.GZIPInputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,8 +40,9 @@ import com.martiansoftware.jsap.stringparsers.ForNameStringParser; import it.unimi.dsi.fastutil.io.BinIO; import it.unimi.dsi.fastutil.objects.AbstractObject2LongFunction; import it.unimi.dsi.fastutil.objects.Object2LongFunction; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; -import it.unimi.dsi.io.FileLinesCollection; +import it.unimi.dsi.io.FileLinesMutableStringIterable; import it.unimi.dsi.lang.MutableString; /** A string map based on a function signed using the original list of strings. @@ -152,7 +153,12 @@ public class LiterallySignedStringMap extends AbstractObject2LongFunction<CharSe final boolean zipped = jsapResult.getBoolean("zipped"); final boolean text = jsapResult.getBoolean("text"); - final ObjectList<MutableString> list = text ? new FileLinesCollection(listName, encoding.toString(), zipped).allLines() : (ObjectList<MutableString>)BinIO.loadObject(listName); + final ObjectList<MutableString> list; + if (text) { + list = new ObjectArrayList<>(); + for (final MutableString s : new FileLinesMutableStringIterable(listName, encoding.toString(), zipped ? GZIPInputStream.class : null)) list.add(s.copy()); + } + else list = (ObjectList<MutableString>)BinIO.loadObject(listName); final Logger logger = LoggerFactory.getLogger(LiterallySignedStringMap.class); logger.info("Signing..."); diff --git a/src/it/unimi/dsi/util/LongInterval.java b/src/it/unimi/dsi/util/LongInterval.java index 69b87f75d467882c0484a3167f675bed84273d31..4882d04bbdaef796273b02c5b096d46fb67ad5e9 100644 --- a/src/it/unimi/dsi/util/LongInterval.java +++ b/src/it/unimi/dsi/util/LongInterval.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2003-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2003-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/LongIntervals.java b/src/it/unimi/dsi/util/LongIntervals.java index 279c24aefec009984b4419c9b7007ec8b7ad0c08..9b001179e10d67a4f6ad06f3ce86532a6b097a39 100644 --- a/src/it/unimi/dsi/util/LongIntervals.java +++ b/src/it/unimi/dsi/util/LongIntervals.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2003-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2003-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/PermutedFrontCodedStringList.java b/src/it/unimi/dsi/util/PermutedFrontCodedStringList.java index b411e47e71a00405d489c0232a412c1352889a6b..3beb9219db21b8eb021731f54d3020825ccad01f 100644 --- a/src/it/unimi/dsi/util/PermutedFrontCodedStringList.java +++ b/src/it/unimi/dsi/util/PermutedFrontCodedStringList.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/PrefixMap.java b/src/it/unimi/dsi/util/PrefixMap.java index c873e7c7b2a1458e8be8ec2b61cd00ca4d8ee7d2..89e79b572c38d2e20e7317d2d31733a6e699168b 100644 --- a/src/it/unimi/dsi/util/PrefixMap.java +++ b/src/it/unimi/dsi/util/PrefixMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2004-2020 Sebastiano Vigna + * Copyright (C) 2004-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/Properties.java b/src/it/unimi/dsi/util/Properties.java index 2717b17514beefef67eae2d965e14084e27214c5..ae7a820247595f9d6c567ed5cf6879e74bd042f1 100644 --- a/src/it/unimi/dsi/util/Properties.java +++ b/src/it/unimi/dsi/util/Properties.java @@ -1,26 +1,26 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -127,6 +127,36 @@ public class Properties extends PropertiesConfiguration implements Serializable fileHandler.save(os); } + /** Loads a configuration from a specified file. + * + * @param filename a file name. + */ + + public void load(final CharSequence filename) throws ConfigurationException, IOException { + final FileInputStream is = new FileInputStream(filename.toString()); + fileHandler.load(is); + is.close(); + } + + /** + * Loads a configuration from a specified file. + * + * @param file a file. + */ + + public void load(final File file) throws ConfigurationException, IOException { + load(file.toString()); + } + + /** + * Loads a configuration from an input stream. + * + * @param is an input stream. + */ + public void load(final InputStream is) throws ConfigurationException { + fileHandler.load(is); + } + /** Adds all properties from the given configuration. * * <p>Properties from the new configuration will clear properties from the first one. diff --git a/src/it/unimi/dsi/util/SemiExternalGammaList.java b/src/it/unimi/dsi/util/SemiExternalGammaList.java index 40a2a2d7dc04956a0e8c56fa482b2d35a80863ca..970a80a61de2b1bf6e5e222a5e813799d2d6615c 100644 --- a/src/it/unimi/dsi/util/SemiExternalGammaList.java +++ b/src/it/unimi/dsi/util/SemiExternalGammaList.java @@ -1,22 +1,21 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - * - */ + * Copyright (C) 2007-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/ShiftAddXorSignedStringMap.java b/src/it/unimi/dsi/util/ShiftAddXorSignedStringMap.java index ddefbfb38cc23c1aade0e75839b0e7a5b4c7f473..4d998306c838e70f405c8ab7fccb083d15e5eda9 100644 --- a/src/it/unimi/dsi/util/ShiftAddXorSignedStringMap.java +++ b/src/it/unimi/dsi/util/ShiftAddXorSignedStringMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2008-2020 Sebastiano Vigna + * Copyright (C) 2008-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/SplitMix64Random.java b/src/it/unimi/dsi/util/SplitMix64Random.java index bbd6c1443b7b35942b8089b673edc1c7df2e4e5d..d0bbcdc60b3eb3b0785c78e57bc3c02bb258be33 100644 --- a/src/it/unimi/dsi/util/SplitMix64Random.java +++ b/src/it/unimi/dsi/util/SplitMix64Random.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2015-2020 Sebastiano Vigna + * Copyright (C) 2015-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/SplitMix64RandomGenerator.java b/src/it/unimi/dsi/util/SplitMix64RandomGenerator.java index ac20b57259c9a6fbcfc80c1d6d531cf3e72f3d06..d4beac254bfba329001a6ab2352ed2030775ef09 100644 --- a/src/it/unimi/dsi/util/SplitMix64RandomGenerator.java +++ b/src/it/unimi/dsi/util/SplitMix64RandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2015-2020 Sebastiano Vigna + * Copyright (C) 2015-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/StringMap.java b/src/it/unimi/dsi/util/StringMap.java index 3e301f35a62177c53515452151651cfbbae9baf7..fc97a35d0a0cc4fd910425419a0426bd51fe8b5f 100644 --- a/src/it/unimi/dsi/util/StringMap.java +++ b/src/it/unimi/dsi/util/StringMap.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2008-2020 Sebastiano Vigna + * Copyright (C) 2008-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/StringMaps.java b/src/it/unimi/dsi/util/StringMaps.java index 0835356105eff5d9ff3f89a67686bd5a247a8802..8cc354d1801d22e3744a5b46556bd2df755397df 100644 --- a/src/it/unimi/dsi/util/StringMaps.java +++ b/src/it/unimi/dsi/util/StringMaps.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2008-2020 Sebastiano Vigna + * Copyright (C) 2008-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/TernaryIntervalSearchTree.java b/src/it/unimi/dsi/util/TernaryIntervalSearchTree.java index a9122c8145ad0d88fff38d43f3ccb6f4fddfc508..71c1c81c9f544fd88e3bd596290f45f8020b70e7 100644 --- a/src/it/unimi/dsi/util/TernaryIntervalSearchTree.java +++ b/src/it/unimi/dsi/util/TernaryIntervalSearchTree.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2005-2020 Sebastiano Vigna + * Copyright (C) 2005-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/TextPattern.java b/src/it/unimi/dsi/util/TextPattern.java index 2d8ea4f2329525ff4d2aa991336ff8f037bf194d..5a13947e1e3ddb8523e0ce0a2e2e7efb88bde5bf 100644 --- a/src/it/unimi/dsi/util/TextPattern.java +++ b/src/it/unimi/dsi/util/TextPattern.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2003-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2003-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandom.java b/src/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandom.java index 942c58fef87607167fd04a9d543961933351c2d9..b8af46859c24ec154e2c87a791afa0b1ba4adfe2 100644 --- a/src/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandom.java +++ b/src/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandom.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomGenerator.java b/src/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomGenerator.java index 2e5e251c5cfb6d5767856f4a209e47621366ac67..3d4619da7687eec0a32c805f6c2c0fe8447f0575 100644 --- a/src/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomGenerator.java +++ b/src/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoRoShiRo128PlusRandom.java b/src/it/unimi/dsi/util/XoRoShiRo128PlusRandom.java index d1477fc64e31e20b2e6efaa48404046770d7f0bf..984f98857323dbb8ffbb2c00e1c140ee0386a54a 100644 --- a/src/it/unimi/dsi/util/XoRoShiRo128PlusRandom.java +++ b/src/it/unimi/dsi/util/XoRoShiRo128PlusRandom.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoRoShiRo128PlusRandomGenerator.java b/src/it/unimi/dsi/util/XoRoShiRo128PlusRandomGenerator.java index e2a89832adb97d42c47746d9b5eb75031d476e9f..0e59f0a547abf2de16130ac7875a594347993b9a 100644 --- a/src/it/unimi/dsi/util/XoRoShiRo128PlusRandomGenerator.java +++ b/src/it/unimi/dsi/util/XoRoShiRo128PlusRandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoRoShiRo128StarStarRandom.java b/src/it/unimi/dsi/util/XoRoShiRo128StarStarRandom.java index 7180de531731263ece137316de55ec6c727f4d7b..ec9f591e89198c6c02424639e7f2c837112ca246 100644 --- a/src/it/unimi/dsi/util/XoRoShiRo128StarStarRandom.java +++ b/src/it/unimi/dsi/util/XoRoShiRo128StarStarRandom.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoRoShiRo128StarStarRandomGenerator.java b/src/it/unimi/dsi/util/XoRoShiRo128StarStarRandomGenerator.java index ee5f25b09ea3994e8f8be22158de1f2c05cf3049..f67e1d2fd2af4c5ad9d1e4cab2480ab43793871d 100644 --- a/src/it/unimi/dsi/util/XoRoShiRo128StarStarRandomGenerator.java +++ b/src/it/unimi/dsi/util/XoRoShiRo128StarStarRandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoShiRo256PlusPlusRandom.java b/src/it/unimi/dsi/util/XoShiRo256PlusPlusRandom.java index b3aa5167b03cf835b92e2f67f4ce99d9f1a555f6..abbf49f4fb4c9b09606253ba7cc1d25dbe71ea37 100644 --- a/src/it/unimi/dsi/util/XoShiRo256PlusPlusRandom.java +++ b/src/it/unimi/dsi/util/XoShiRo256PlusPlusRandom.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoShiRo256PlusPlusRandomGenerator.java b/src/it/unimi/dsi/util/XoShiRo256PlusPlusRandomGenerator.java index 0bb68201c96774d72043fc891a08f47c9c26a5cb..98a60121fa6f57f9643688c1e9d48b5048af82f7 100644 --- a/src/it/unimi/dsi/util/XoShiRo256PlusPlusRandomGenerator.java +++ b/src/it/unimi/dsi/util/XoShiRo256PlusPlusRandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoShiRo256PlusRandom.java b/src/it/unimi/dsi/util/XoShiRo256PlusRandom.java index a4ec8a66427bcb71f747be0cae157a616b58945c..70664cb2252cac4584ea7044534353f6039ceca7 100644 --- a/src/it/unimi/dsi/util/XoShiRo256PlusRandom.java +++ b/src/it/unimi/dsi/util/XoShiRo256PlusRandom.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoShiRo256PlusRandomGenerator.java b/src/it/unimi/dsi/util/XoShiRo256PlusRandomGenerator.java index ba1c1a14cd37a59c66454d1a77713986c4cd6276..588d6c7dc6f8278f7031d0b5ef5df154090c7b98 100644 --- a/src/it/unimi/dsi/util/XoShiRo256PlusRandomGenerator.java +++ b/src/it/unimi/dsi/util/XoShiRo256PlusRandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoShiRo256StarStarRandom.java b/src/it/unimi/dsi/util/XoShiRo256StarStarRandom.java index 565f07a2a333f5fb64506694a339dc9b91bbde46..5a75cd1a3a11f7b09fc2daa09b5bae2bb9b493d8 100644 --- a/src/it/unimi/dsi/util/XoShiRo256StarStarRandom.java +++ b/src/it/unimi/dsi/util/XoShiRo256StarStarRandom.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XoShiRo256StarStarRandomGenerator.java b/src/it/unimi/dsi/util/XoShiRo256StarStarRandomGenerator.java index 974da0401e11d075c2a4fd9581056ca3178e07d4..d40b9114289b4035cb47102339fa6a3fa00ef9a5 100644 --- a/src/it/unimi/dsi/util/XoShiRo256StarStarRandomGenerator.java +++ b/src/it/unimi/dsi/util/XoShiRo256StarStarRandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XorGensRandomGenerator.java b/src/it/unimi/dsi/util/XorGensRandomGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..0d139d9c5735ae93af1cef8d7dd71e556d33f37b --- /dev/null +++ b/src/it/unimi/dsi/util/XorGensRandomGenerator.java @@ -0,0 +1,146 @@ +/* + * DSI utilities + * + * Copyright (C) 2012-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.util; + +import java.io.Serializable; + +import org.apache.commons.math3.random.AbstractRandomGenerator; +import org.apache.commons.math3.random.RandomGenerator; + +import it.unimi.dsi.Util; + +/** A fast, high-quality 64-bit {@linkplain RandomGenerator pseudorandom number generator} described in “Some long-period random number generators using shift + * and xors”, <i>ANZIAM Journal</i> 48, C188−C202, 2007. */ + +public class XorGensRandomGenerator extends AbstractRandomGenerator implements Serializable { + private static final long serialVersionUID = 0L; + private static final int WLEN = 64; + private static final int R = 64; + private static final int S = 53; + private static final int A = 33; + private static final int B = 26; + private static final int C = 27; + private static final int D = 29; + private static final long WEYL = 0x61c8864680b583ebL; + /** State of the Xorshift generator. */ + private final long[] x = new long[R]; + private long weyl; + private int i; + + /** Creates a new generator, initializing its seed with {@link Util#randomSeed()}. */ + public XorGensRandomGenerator() { + this(Util.randomSeed()); + } + + /** Creates a new generator using a given seed. + * + * @param seed a nonzero seed for the generator (if zero, the generator will be seeded with -1). + */ + public XorGensRandomGenerator(final long seed) { + setSeed(seed); + } + + @Override + public void setSeed(final long seed) { + long v = seed == 0 ? -1 : seed; /* v must be nonzero */ + for (int k = WLEN; k > 0; k--) { /* Avoid correlations for close seeds */ + v ^= v << 10; + v ^= v >>> 15; /* Recurrence has period 2**wlen-1 */ + v ^= v << 4; + v ^= v >>> 13; /* for wlen = 32 or 64 */ + } + + for (int k = 0; k < R; k++) { /* Initialise circular array */ + v ^= v << 10; + v ^= v >>> 15; + v ^= v << 4; + v ^= v >>> 13; + x[k] = v; + } + + i = R - 1; + + long t; + for (int k = 4 * R; k > 0; k--) { /* Discard first 4*r results */ + t = x[i = (i + 1) & (R - 1)]; + t ^= t << A; + t ^= t >>> B; + v = x[(i + (R - S)) & (R - 1)]; + v ^= v << C; + v ^= v >>> D; + x[i] = t ^ v; + } + } + + @Override + public long nextLong() { + long t, v; + t = x[i = (i + 1) & (R - 1)]; /* Assumes that r is a power of two */ + v = x[(i + (R - S)) & (R - 1)]; /* Index is (i-s) mod r */ + t ^= t << A; + v ^= v << C; + t ^= t >>> B; /* (I + L^a)(I + R^b) */ + v ^= v >>> D; /* (I + L^c)(I + R^d) */ + x[i] = (v ^= t); /* Update circular array */ + weyl += WEYL; + return (v + (weyl ^ (weyl >>> 27))); + } + + @Override + public int nextInt() { + return (int)nextLong(); + } + + @Override + public int nextInt(final int n) { + return (int)nextLong(n); + } + + public long nextLong(final long n) { + if (n <= 0) throw new IllegalArgumentException(); + // No special provision for n power of two: all our bits are good. + for(;;) { + final long bits = nextLong() >>> 1; + final long value = bits % n; + if (bits - value + (n - 1) >= 0) return value; + } + } + + @Override + public double nextDouble() { + return (nextLong() >>> 11) * 0x1.0p-53; + } + + @Override + public float nextFloat() { + return (nextLong() >>> 40) * 0x1.0p-24f; + } + + @Override + public boolean nextBoolean() { + return nextLong() < 0; + } + + @Override + public void nextBytes(final byte[] bytes) { + for (int i = bytes.length; i != 0;) + for (long bits = nextLong(), n = Math.min(i, 8); n-- != 0; bits >>= 8) bytes[--i] = (byte)bits; + } +} diff --git a/src/it/unimi/dsi/util/XorShift1024StarPhiRandom.java b/src/it/unimi/dsi/util/XorShift1024StarPhiRandom.java index 89ec59a32ff64e639c8f24bc7b7f696a7ca59c41..a976170d37d5b8c2ec863321aabc4f92aa0bdd05 100644 --- a/src/it/unimi/dsi/util/XorShift1024StarPhiRandom.java +++ b/src/it/unimi/dsi/util/XorShift1024StarPhiRandom.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XorShift1024StarPhiRandomGenerator.java b/src/it/unimi/dsi/util/XorShift1024StarPhiRandomGenerator.java index fdf2e4c846c6d15ee4f19f168415e7019fd3055e..31409f42f04e89c7e1f3b11201e22fdba46a13fd 100644 --- a/src/it/unimi/dsi/util/XorShift1024StarPhiRandomGenerator.java +++ b/src/it/unimi/dsi/util/XorShift1024StarPhiRandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XorShift1024StarRandom.java b/src/it/unimi/dsi/util/XorShift1024StarRandom.java index 5980546597e137b87ba8fc972f053c5912aca9ad..6e37fb2c56eb26e7e2173c7a2e17c4d451b58e94 100644 --- a/src/it/unimi/dsi/util/XorShift1024StarRandom.java +++ b/src/it/unimi/dsi/util/XorShift1024StarRandom.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XorShift1024StarRandomGenerator.java b/src/it/unimi/dsi/util/XorShift1024StarRandomGenerator.java index ff23ebcd5fee250255562efc6c2462d942bbe067..2d6c907f01822ade8599bc7f8d132ef111bdea4d 100644 --- a/src/it/unimi/dsi/util/XorShift1024StarRandomGenerator.java +++ b/src/it/unimi/dsi/util/XorShift1024StarRandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XorShift128PlusRandom.java b/src/it/unimi/dsi/util/XorShift128PlusRandom.java index 12a821b5936754bdd870a79caf51bb2e1faea5ef..7c8e5887155e21d485e1e9b4ad1681f4693d926a 100644 --- a/src/it/unimi/dsi/util/XorShift128PlusRandom.java +++ b/src/it/unimi/dsi/util/XorShift128PlusRandom.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XorShift128PlusRandomGenerator.java b/src/it/unimi/dsi/util/XorShift128PlusRandomGenerator.java index 7d156fd3df1484cd37f8c96904350f2d58f0e949..d6250bc3a4969744d3278c0b5bbbc2e1d5e00515 100644 --- a/src/it/unimi/dsi/util/XorShift128PlusRandomGenerator.java +++ b/src/it/unimi/dsi/util/XorShift128PlusRandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/XorShift64StarRandom.java b/src/it/unimi/dsi/util/XorShift64StarRandom.java index 4f09e37ec2a5748dca5096081287bc012b707551..6ce89720cdd0747d4dafef56be57bc59c1f5f3c5 100644 --- a/src/it/unimi/dsi/util/XorShift64StarRandom.java +++ b/src/it/unimi/dsi/util/XorShift64StarRandom.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2011-2020 Sebastiano Vigna + * Copyright (C) 2011-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ diff --git a/src/it/unimi/dsi/util/XorShift64StarRandomGenerator.java b/src/it/unimi/dsi/util/XorShift64StarRandomGenerator.java index fcb453bf8ebba3e6165e8e370dbd59d3323ce909..46defafdefb8131fa85852c4a5a96fe3d052adb6 100644 --- a/src/it/unimi/dsi/util/XorShift64StarRandomGenerator.java +++ b/src/it/unimi/dsi/util/XorShift64StarRandomGenerator.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2012-2020 Sebastiano Vigna + * Copyright (C) 2012-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/src/it/unimi/dsi/util/concurrent/ReorderingBlockingQueue.java b/src/it/unimi/dsi/util/concurrent/ReorderingBlockingQueue.java index 7dc8bb8d56a8e2a9c5ac2a50ee9d0104c86d8189..3a8d1ed3543e0a8088cf741272dc040b348ebefe 100644 --- a/src/it/unimi/dsi/util/concurrent/ReorderingBlockingQueue.java +++ b/src/it/unimi/dsi/util/concurrent/ReorderingBlockingQueue.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2017-2020 Sebastiano Vigna + * Copyright (C) 2017-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util.concurrent; diff --git a/src/it/unimi/dsi/util/concurrent/package-info.java b/src/it/unimi/dsi/util/concurrent/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..3b73f72f1c34ca1b84c9d7b5ca0198a9808dde46 --- /dev/null +++ b/src/it/unimi/dsi/util/concurrent/package-info.java @@ -0,0 +1,3 @@ +/** Concurrent data structures */ + +package it.unimi.dsi.util.concurrent; diff --git a/src/it/unimi/dsi/util/package-info.java b/src/it/unimi/dsi/util/package-info.java index f4b53d071c93f8b4cf17b897c94f33daa78982b2..e66df09fae473ef807f113e797dd40c3887d0121 100644 --- a/src/it/unimi/dsi/util/package-info.java +++ b/src/it/unimi/dsi/util/package-info.java @@ -1,5 +1,5 @@ /** - * <p>Miscellaneaous utility classes. + * Miscellaneous utility classes * * <h2>Pseudorandom number generators</h2> * diff --git a/src/overview.html b/src/overview.html index fd4b48b119ef8d6a3eef84a0e366fe96f406a74e..8645f112923ec23812b6fac9905dc20c3b9258c5 100644 --- a/src/overview.html +++ b/src/overview.html @@ -13,8 +13,8 @@ (mainly in <a href="http://mg4j.di.unimi.it/">MG4J</a>) but we finally decided to gather all the material in a single place. - <P>The DSI utilities are distributed under the <A - HREF="http://www.gnu.org/copyleft/lesser.html">GNU Lesser General Public License</A>. + <P>The DSI utilities are free software + distributed under either the <A HREF="https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">GNU Lesser General Public License 2.1+</A> or the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache Software License 2.0</a>. <h1>Highlights</h1> @@ -31,18 +31,16 @@ line.</li> <li>{@link it.unimi.dsi.lang.MutableString}, our answer to the Java {@link java.lang.String} class.</li> <li>The {@link it.unimi.dsi.io I/O package}, containing fast version of several classes existing in {@link java.io}, - many useful classes to read easily text data (e.g., {@link it.unimi.dsi.io.FileLinesCollection}), {@linkplain it.unimi.dsi.io.InputBitStream bit streams}, + many useful classes to read easily text data (e.g., {@link it.unimi.dsi.io.FileLinesMutableStringIterable}), {@linkplain it.unimi.dsi.io.InputBitStream bit streams}, classes providing large-size memory mapping such as {@link it.unimi.dsi.io.ByteBufferInputStream}, and {@link it.unimi.dsi.io.OfflineIterable}—the easy & fast way to store large sequences of objects on disk and iterate on them.</li> - <li>The {@link it.unimi.dsi.util} package, containing pseudorandom number generators, {@linkplain it.unimi.dsi.util.ImmutableBinaryTrie tries}, + <li>The {@link it.unimi.dsi.util} package, containing {@linkplain it.unimi.dsi.util.ImmutableBinaryTrie tries}, {@linkplain it.unimi.dsi.util.ImmutableExternalPrefixMap immutable prefix maps}, {@linkplain it.unimi.dsi.util.BloomFilter Bloom filters}, a very comfortable {@link it.unimi.dsi.util.Properties} class and more.</li> <li>The {@link it.unimi.dsi.stat} package, containing a lightweight class for {@linkplain it.unimi.dsi.stat.SummaryStats computing basic statistics} and {@linkplain it.unimi.dsi.stat.Jackknife an arbitrary-precision implementation of the Jackknife method}.</li> <li>Lots of utility methods in {@link it.unimi.dsi.Util} (have a look!)</li> - <li><em>Big</em> versions of I/O and utility classes - in {@link it.unimi.dsi.big.io} and {@link it.unimi.dsi.big.util}.</li> - <li>The {@link it.unimi.dsi.parser.BulletParser}, that we use to parse HTML and XML.</li> + <li><em>Big</em> versions of I/O and utility classes in {@link it.unimi.dsi.big.io} and {@link it.unimi.dsi.big.util}.</li> </ul> </body> </html> diff --git a/src/stylesheet.css b/src/stylesheet.css new file mode 100644 index 0000000000000000000000000000000000000000..d134ace2c39880653fce6af5904972d2d648c521 --- /dev/null +++ b/src/stylesheet.css @@ -0,0 +1,482 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ +body { + background-color:#ffffff; + color:#353833; + font-family:Arial, Helvetica, sans-serif; + font-size:76%; + margin:0; +} +p { + font-size:1em; +} +a:link, a:visited { + text-decoration:none; + color:#4c6b87; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4c6b87; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-size:1.2em; +} +h1 { + font-size:1.8em; +} +h2 { + font-size:1.5em; +} +h3 { + font-size:1.4em; +} +h4 { + font-size:1.3em; +} +h5 { + font-size:1.2em; +} +h6 { + font-size:1.1em; +} +ul { + list-style-type:disc; + font-size:1em; +} +code, tt { + font-size:1.2em; +} +dt code { + font-size:1.2em; +} +table tr td dt code { + font-size:1.2em; + vertical-align:top; +} +sup { + font-size:.6em; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:.8em; + z-index:200; + margin-top:-7px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + background-image:url(resources/titlebar.gif); + background-position:left top; + background-repeat:no-repeat; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:1em; + margin:0; +} +.topNav { + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.bottomNav { + margin-top:10px; + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.subNav { + background-color:#dee3e9; + border-bottom:1px solid #9eadc0; + float:left; + width:100%; + overflow:hidden; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding:3px 6px; +} +ul.subNavList li{ + list-style:none; + float:left; + font-size:90%; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; +} +.navBarCell1Rev { + background-image:url(resources/tab.gif); + background-color:#a88834; + color:#FFFFFF; + margin: auto 5px; + border:1px solid #c9aa44; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader h1 { + font-size:1.3em; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 25px 0; + padding:0; + list-style-type:circle; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:inherit; + -webkit-margin-before: 1em; + -webkit-margin-after: 1em; + -webkit-margin-start: 0px; + -webkit-margin-end: 0px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0 0 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0 0 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:1.0em; +} +.indexContainer h2 { + font-size:1.1em; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:1.1em; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:10px 0 10px 20px; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:25px; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #9eadc0; + background-color:#f9f9f9; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:1px solid #9eadc0; + border-top:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; + border-bottom:1px solid #9eadc0; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.contentContainer table, .classUseContainer table, .constantValuesContainer table { + border-bottom:1px solid #9eadc0; + width:100%; +} +.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table { + width:100%; +} +.contentContainer .description table, .contentContainer .details table { + border-bottom:none; +} +.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{ + vertical-align:top; + padding-right:20px; +} +.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast, +.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast, +.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne, +.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne { + padding-right:3px; +} +.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#FFFFFF; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + margin:0px; +} +caption a:link, caption a:hover, caption a:active, caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span { + white-space:nowrap; + padding-top:8px; + padding-left:8px; + display:block; + float:left; + background-image:url(resources/titlebar.gif); + height:18px; +} +.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { + width:10px; + background-image:url(resources/titlebar_end.gif); + background-repeat:no-repeat; + background-position:top right; + position:relative; + float:left; +} +ul.blockList ul.blockList li.blockList table { + margin:0 0 12px 0px; + width:100%; +} +.tableSubHeadingColor { + background-color: #EEEEFF; +} +.altColor { + background-color:#eeeeef; +} +.rowColor { + background-color:#ffffff; +} +.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td { + text-align:left; + padding:3px 3px 3px 7px; +} +th.colFirst, th.colLast, th.colOne, .constantValuesContainer th { + background:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + text-align:left; + padding:3px 3px 3px 7px; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +td.colFirst, th.colFirst { + border-left:1px solid #9eadc0; + white-space:nowrap; +} +td.colLast, th.colLast { + border-right:1px solid #9eadc0; +} +td.colOne, th.colOne { + border-right:1px solid #9eadc0; + border-left:1px solid #9eadc0; +} +table.overviewSummary { + padding:0px; + margin-left:0px; +} +table.overviewSummary td.colFirst, table.overviewSummary th.colFirst, +table.overviewSummary td.colOne, table.overviewSummary th.colOne { + width:25%; + vertical-align:middle; +} +table.packageSummary td.colFirst, table.overviewSummary th.colFirst { + width:25%; + vertical-align:middle; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:.9em; +} +.block { + display:block; + margin:3px 0 0 0; +} +.strong { + font-weight:bold; +} diff --git a/test/it/unimi/dsi/UtilTest.java b/test/it/unimi/dsi/UtilTest.java index 23cee51162774bd042b8ec6e3758a0c5be7db952..19ca3687518d900dbbedf762f273b9b6241b4d18 100644 --- a/test/it/unimi/dsi/UtilTest.java +++ b/test/it/unimi/dsi/UtilTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi; diff --git a/test/it/unimi/dsi/big/util/FrontCodedStringBigListTest.java b/test/it/unimi/dsi/big/util/FrontCodedStringBigListTest.java index 492c82389ecd58a930c66a6d6bbb14017f2404bb..c9be6e5a9464991aa9547dd6705d08b45e8d6107 100644 --- a/test/it/unimi/dsi/big/util/FrontCodedStringBigListTest.java +++ b/test/it/unimi/dsi/big/util/FrontCodedStringBigListTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/test/it/unimi/dsi/big/util/ImmutableBinaryTrieTest.java b/test/it/unimi/dsi/big/util/ImmutableBinaryTrieTest.java index a86b84d72e6cc8a6fa0b478857a79c62c5c803ee..56ef0ef20e92ef5c75fb5d71dd361ab9f6b0ee5a 100644 --- a/test/it/unimi/dsi/big/util/ImmutableBinaryTrieTest.java +++ b/test/it/unimi/dsi/big/util/ImmutableBinaryTrieTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/test/it/unimi/dsi/big/util/ImmutableExternalPrefixMapTest.java b/test/it/unimi/dsi/big/util/ImmutableExternalPrefixMapTest.java index 7fe6401f0bbb828369d611de1c2d0807cc38db33..4e98767ceead921330387c8d834bd3d7c383e2b6 100644 --- a/test/it/unimi/dsi/big/util/ImmutableExternalPrefixMapTest.java +++ b/test/it/unimi/dsi/big/util/ImmutableExternalPrefixMapTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/test/it/unimi/dsi/big/util/LiterallySignedStringMapTest.java b/test/it/unimi/dsi/big/util/LiterallySignedStringMapTest.java index 62ee7e3cbfa0e168ad74ec6de881f7ca9f77438a..506c83300a8513406487fab52654764ed5805fbd 100644 --- a/test/it/unimi/dsi/big/util/LiterallySignedStringMapTest.java +++ b/test/it/unimi/dsi/big/util/LiterallySignedStringMapTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/test/it/unimi/dsi/big/util/LongBigArraySignedStringMapTest.java b/test/it/unimi/dsi/big/util/LongBigArraySignedStringMapTest.java index 3302263e447606666f138c453ec526d37cb63465..3aab61cf249e89ceb571cc8ff3b6300a99990e85 100644 --- a/test/it/unimi/dsi/big/util/LongBigArraySignedStringMapTest.java +++ b/test/it/unimi/dsi/big/util/LongBigArraySignedStringMapTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/test/it/unimi/dsi/big/util/SemiExternalGammaBigListTest.java b/test/it/unimi/dsi/big/util/SemiExternalGammaBigListTest.java index 04b45376e28c31904044878fb8a070af74b1ae2f..bfd3efababa6895ac769f21af5b61e92c87fd027 100644 --- a/test/it/unimi/dsi/big/util/SemiExternalGammaBigListTest.java +++ b/test/it/unimi/dsi/big/util/SemiExternalGammaBigListTest.java @@ -1,22 +1,21 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - * - */ + * Copyright (C) 2002-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ package it.unimi.dsi.big.util; diff --git a/test/it/unimi/dsi/big/util/ShiftAddXorSignedStringMapTest.java b/test/it/unimi/dsi/big/util/ShiftAddXorSignedStringMapTest.java index bcd898d36b3ca5419f0326e1253f1c543af4ff99..373e8aaeca85acf3774eb42f4749c610d61715bc 100644 --- a/test/it/unimi/dsi/big/util/ShiftAddXorSignedStringMapTest.java +++ b/test/it/unimi/dsi/big/util/ShiftAddXorSignedStringMapTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/test/it/unimi/dsi/big/util/TernaryIntervalSearchTreeTest.java b/test/it/unimi/dsi/big/util/TernaryIntervalSearchTreeTest.java index ca60f7c44d07c88ab5fbf87230948014d9e04e07..74be4e7fb5118a1a253df6221cad75dc66469f9f 100644 --- a/test/it/unimi/dsi/big/util/TernaryIntervalSearchTreeTest.java +++ b/test/it/unimi/dsi/big/util/TernaryIntervalSearchTreeTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2002-2020 Sebastiano Vigna + * Copyright (C) 2002-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.big.util; diff --git a/test/it/unimi/dsi/bits/AbstractBitVectorTest.java b/test/it/unimi/dsi/bits/AbstractBitVectorTest.java index ef750d1587d37216796aaa711fd4710e1e7ce9ed..ab13239a8e28bd8dd5ea2b1e625600f131dfcbcc 100644 --- a/test/it/unimi/dsi/bits/AbstractBitVectorTest.java +++ b/test/it/unimi/dsi/bits/AbstractBitVectorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/BitVectorTestCase.java b/test/it/unimi/dsi/bits/BitVectorTestCase.java index b064cd6eba6fb7d03b3b66f26a2ae1351a0de8e6..c1073494eedf500da56f9df16fd081d8ad1835fe 100644 --- a/test/it/unimi/dsi/bits/BitVectorTestCase.java +++ b/test/it/unimi/dsi/bits/BitVectorTestCase.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/BitVectorsTest.java b/test/it/unimi/dsi/bits/BitVectorsTest.java index 8cae2bc32f0a6eb2de97005bd7e97ff0af3da996..c7cd1ba50d9074cecd5f40857fe9f3d7bbf11c0a 100644 --- a/test/it/unimi/dsi/bits/BitVectorsTest.java +++ b/test/it/unimi/dsi/bits/BitVectorsTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/BooleanListBitVectorTest.java b/test/it/unimi/dsi/bits/BooleanListBitVectorTest.java index 2b32dc4f495c4effeea01c18c9d98cb3dd752ba6..fdcb8ea49a9a6515d72eb421e83df546ee6d8942 100644 --- a/test/it/unimi/dsi/bits/BooleanListBitVectorTest.java +++ b/test/it/unimi/dsi/bits/BooleanListBitVectorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/ByteArrayTransformationStrategyTest.java b/test/it/unimi/dsi/bits/ByteArrayTransformationStrategyTest.java index fd730553c6629745cfa02996b771c7303001f5b5..5f718e31d5ee13e148b710e937bdc644144ec107 100644 --- a/test/it/unimi/dsi/bits/ByteArrayTransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/ByteArrayTransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; @@ -43,6 +42,7 @@ public class ByteArrayTransformationStrategyTest { assertEquals(128, TransformationStrategies.byteArray().toBitVector(a).getLong(0, 64)); assertEquals(0xF000000000000008L, TransformationStrategies.byteArray().toBitVector(a).getLong(4, 68)); assertEquals(-1L, TransformationStrategies.byteArray().toBitVector(a).getLong(64, 128)); + assertEquals(0, TransformationStrategies.byteArray().toBitVector(a).getLong(128, 136)); for(int i = 1; i < 7; i++) assertEquals(0, TransformationStrategies.byteArray().toBitVector(a).getLong(0, i)); @@ -50,4 +50,28 @@ public class ByteArrayTransformationStrategyTest { for(int i = 8; i < 63; i++) assertEquals(128, TransformationStrategies.byteArray().toBitVector(a).getLong(0, i)); } + + @Test + public void testGetLongPrefixFree() { + byte[] a = new byte[] { 0x55, (byte)0xFF }; + assertEquals(24, TransformationStrategies.prefixFreeByteArray().toBitVector(a).length()); + System.err.println(Long.toHexString(TransformationStrategies.prefixFreeByteArray().toBitVector(a).getLong(0, 24))); + assertEquals(0x00FFAAL, TransformationStrategies.prefixFreeByteArray().toBitVector(a).getLong(0, 24)); + + a = new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 0 }; + assertFalse(TransformationStrategies.prefixFreeByteArray().toBitVector(a).getBoolean(0)); + assertFalse(TransformationStrategies.prefixFreeByteArray().toBitVector(a).getBoolean(1)); + assertTrue(TransformationStrategies.prefixFreeByteArray().toBitVector(a).getBoolean(7)); + assertTrue(TransformationStrategies.prefixFreeByteArray().toBitVector(a).getBoolean(64)); + assertEquals(128, TransformationStrategies.prefixFreeByteArray().toBitVector(a).getLong(0, 56)); + assertEquals(128, TransformationStrategies.prefixFreeByteArray().toBitVector(a).getLong(0, 64)); + assertEquals(0xF000000000000008L, TransformationStrategies.prefixFreeByteArray().toBitVector(a).getLong(4, 68)); + assertEquals(-1L, TransformationStrategies.prefixFreeByteArray().toBitVector(a).getLong(64, 128)); + assertEquals(0, TransformationStrategies.prefixFreeByteArray().toBitVector(a).getLong(128, 136)); + assertEquals(0, TransformationStrategies.prefixFreeByteArray().toBitVector(a).getLong(136, 144)); + + for (int i = 1; i < 7; i++) assertEquals(0, TransformationStrategies.prefixFreeByteArray().toBitVector(a).getLong(0, i)); + + for (int i = 8; i < 63; i++) assertEquals(128, TransformationStrategies.prefixFreeByteArray().toBitVector(a).getLong(0, i)); + } } diff --git a/test/it/unimi/dsi/bits/FastTest.java b/test/it/unimi/dsi/bits/FastTest.java index bfa243d41b380a2940a09be01c64594d5e073634..a799ce6566412a39e34db69718d3d0fe4769d797 100644 --- a/test/it/unimi/dsi/bits/FastTest.java +++ b/test/it/unimi/dsi/bits/FastTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/FixedLongTransformationStrategyTest.java b/test/it/unimi/dsi/bits/FixedLongTransformationStrategyTest.java index c9f01aded1adb33756393297372d5d5f28929582..54db78c04b7a1c465ead98cb81557888ad3516e6 100644 --- a/test/it/unimi/dsi/bits/FixedLongTransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/FixedLongTransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/IsoTransformationStrategyTest.java b/test/it/unimi/dsi/bits/IsoTransformationStrategyTest.java index a70497df42e8d79e317a835aad488c368be2f28c..b90a57277c285679627470f765714328413ac4e5 100644 --- a/test/it/unimi/dsi/bits/IsoTransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/IsoTransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/LongArrayBitVectorTest.java b/test/it/unimi/dsi/bits/LongArrayBitVectorTest.java index bd5164324d92297a3e0e5146a1a002401737d61d..1032e7df2fd79abbcf07c5b264bebe319d479182 100644 --- a/test/it/unimi/dsi/bits/LongArrayBitVectorTest.java +++ b/test/it/unimi/dsi/bits/LongArrayBitVectorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/LongBigArrayBitVectorTest.java b/test/it/unimi/dsi/bits/LongBigArrayBitVectorTest.java index 1508fd67290cab401a3e3b0d3e79ae863b1238ee..10c8352c8b1c567c1c5c995f853159094de015e7 100644 --- a/test/it/unimi/dsi/bits/LongBigArrayBitVectorTest.java +++ b/test/it/unimi/dsi/bits/LongBigArrayBitVectorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/PrefixFreeTransformationStrategyTest.java b/test/it/unimi/dsi/bits/PrefixFreeTransformationStrategyTest.java index 83ae1b0257138b20454f361a444870c285c2e2af..ac6ca4a5b29b39a6e19a281638f585f0aac823d7 100644 --- a/test/it/unimi/dsi/bits/PrefixFreeTransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/PrefixFreeTransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/RawByteArrayTransformationStrategyTest.java b/test/it/unimi/dsi/bits/RawByteArrayTransformationStrategyTest.java index b4c14fa10d4db873cc473482f8fce9c6bb2a22ef..6f0db198abd844e943f153854df1b9718aa07630 100644 --- a/test/it/unimi/dsi/bits/RawByteArrayTransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/RawByteArrayTransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/RawFixedLongTransformationStrategyTest.java b/test/it/unimi/dsi/bits/RawFixedLongTransformationStrategyTest.java index 511e16184577624d976c6e0951b13bd52df63b40..a50d60c05f895139e7a680c38e4e8c34e79ade2e 100644 --- a/test/it/unimi/dsi/bits/RawFixedLongTransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/RawFixedLongTransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/RawISOTransformationStrategyTest.java b/test/it/unimi/dsi/bits/RawISOTransformationStrategyTest.java index 728d623f6b06327c76f3bf6cc3e39f2dc9618907..241e1702ddae98066b8c32315bee16430852b7b2 100644 --- a/test/it/unimi/dsi/bits/RawISOTransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/RawISOTransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/RawUtf16TransformationStrategyTest.java b/test/it/unimi/dsi/bits/RawUtf16TransformationStrategyTest.java index 30c1dfe30c6ba16ac0d9aa5229dbc7a1207ee964..2a588577f2ca4e8409e40529bae4bfbdc617e281 100644 --- a/test/it/unimi/dsi/bits/RawUtf16TransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/RawUtf16TransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/RawUtf32TransformationStrategyTest.java b/test/it/unimi/dsi/bits/RawUtf32TransformationStrategyTest.java index c272c3b2e9dcf386ecc1224e091907b76d64cbb8..b1de369c630752b4c7bf933545dfb62b8ded701b 100644 --- a/test/it/unimi/dsi/bits/RawUtf32TransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/RawUtf32TransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/Utf16TransformationStrategyTest.java b/test/it/unimi/dsi/bits/Utf16TransformationStrategyTest.java index a6088652237aaeeca17c94a81c428912b1ccd865..f184e9e7cbe46a2659ea2fcc5d394866d0712598 100644 --- a/test/it/unimi/dsi/bits/Utf16TransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/Utf16TransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/bits/Utf32TransformationStrategyTest.java b/test/it/unimi/dsi/bits/Utf32TransformationStrategyTest.java index e8b64c11acda49a46587708cf782cb0347c09b8c..8635bab0d242b60cf4d1ee27d11012f77a3c923d 100644 --- a/test/it/unimi/dsi/bits/Utf32TransformationStrategyTest.java +++ b/test/it/unimi/dsi/bits/Utf32TransformationStrategyTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.bits; diff --git a/test/it/unimi/dsi/compression/CodecTestCase.java b/test/it/unimi/dsi/compression/CodecTestCase.java index 5b546974a04e2a86b7d780c37f964c798eb1722c..8a16659b26551b46044b14bcaaf6409f77ad605a 100644 --- a/test/it/unimi/dsi/compression/CodecTestCase.java +++ b/test/it/unimi/dsi/compression/CodecTestCase.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/test/it/unimi/dsi/compression/HuTuckerCodecTest.java b/test/it/unimi/dsi/compression/HuTuckerCodecTest.java index f0fe928269ba878dd9d39e91b8b1b85e15e4dbbb..c4ec251806fa0f4eb1b246ee4bdc9f98c92a0cb1 100644 --- a/test/it/unimi/dsi/compression/HuTuckerCodecTest.java +++ b/test/it/unimi/dsi/compression/HuTuckerCodecTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/test/it/unimi/dsi/compression/HuffmanCodecTest.java b/test/it/unimi/dsi/compression/HuffmanCodecTest.java index 89b78bb30830b9a7707265d14514a26a1992cfad..31fe10d2c0e8d52ebdc25b19cb5dc276a8d4e621 100644 --- a/test/it/unimi/dsi/compression/HuffmanCodecTest.java +++ b/test/it/unimi/dsi/compression/HuffmanCodecTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2007-2020 Sebastiano Vigna + * Copyright (C) 2007-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.compression; diff --git a/test/it/unimi/dsi/io/ByteBufferInputStreamTest.java b/test/it/unimi/dsi/io/ByteBufferInputStreamTest.java index 228a38c66546e11bb9b5f5d04c591c0a62d76186..b49d734edb444cf758e47bf435a87203ee86a6d5 100644 --- a/test/it/unimi/dsi/io/ByteBufferInputStreamTest.java +++ b/test/it/unimi/dsi/io/ByteBufferInputStreamTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/test/it/unimi/dsi/io/ByteDiskQueueTest.java b/test/it/unimi/dsi/io/ByteDiskQueueTest.java index 5a929b4ef79d84c047b2a5b8393fc3948ee0c1f2..5b56610777563c490f7338cabb0b46906cf5fe13 100644 --- a/test/it/unimi/dsi/io/ByteDiskQueueTest.java +++ b/test/it/unimi/dsi/io/ByteDiskQueueTest.java @@ -1,19 +1,20 @@ /* - * Copyright (C) 2014-2020 Sebastiano Vigna + * DSI utilities * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/test/it/unimi/dsi/io/DelimitedWordReaderTest.java b/test/it/unimi/dsi/io/DelimitedWordReaderTest.java index cc672ffa61cf6a598fb9f0537c18ac87fcd9f2a7..9c2f90b10cccb671f54d232f9a6330c1234eff05 100644 --- a/test/it/unimi/dsi/io/DelimitedWordReaderTest.java +++ b/test/it/unimi/dsi/io/DelimitedWordReaderTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/test/it/unimi/dsi/io/FastBufferedReaderTest.java b/test/it/unimi/dsi/io/FastBufferedReaderTest.java index 3de80e00c6ad56c0d3775d516133f2427c373577..ab0bf363431e63c99ca98eac196490648058486c 100644 --- a/test/it/unimi/dsi/io/FastBufferedReaderTest.java +++ b/test/it/unimi/dsi/io/FastBufferedReaderTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/test/it/unimi/dsi/io/FileLinesByteArrayCollectionTest.java b/test/it/unimi/dsi/io/FileLinesByteArrayCollectionTest.java index b6caf47a55d5287689015e6442fd3384a8923942..4bb3c8ba7703076ec0b21ed3d0a4a8949187715f 100644 --- a/test/it/unimi/dsi/io/FileLinesByteArrayCollectionTest.java +++ b/test/it/unimi/dsi/io/FileLinesByteArrayCollectionTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2016-2020 Sebastiano Vigna + * Copyright (C) 2016-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; @@ -31,12 +30,11 @@ import java.util.Arrays; import org.junit.Test; -import it.unimi.dsi.big.io.FileLinesByteArrayCollection; -import it.unimi.dsi.big.io.FileLinesByteArrayCollection.FileLinesIterator; import it.unimi.dsi.fastutil.io.BinIO; public class FileLinesByteArrayCollectionTest { + @SuppressWarnings("deprecation") @Test public void test() throws IOException { final File file = File.createTempFile(FastBufferedReaderTest.class.getSimpleName(), "tmp"); @@ -44,8 +42,8 @@ public class FileLinesByteArrayCollectionTest { byte[] a = { '0', '\n', '1', '\n' }; BinIO.storeBytes(a, file); - FileLinesByteArrayCollection flbac = new FileLinesByteArrayCollection(file.toString()); - FileLinesIterator iterator = flbac.iterator(); + it.unimi.dsi.big.io.FileLinesByteArrayCollection flbac = new it.unimi.dsi.big.io.FileLinesByteArrayCollection(file.toString()); + it.unimi.dsi.big.io.FileLinesByteArrayCollection.FileLinesIterator iterator = flbac.iterator(); assertArrayEquals(new byte[] { '0' }, iterator.next()); assertArrayEquals(new byte[] { '1' }, iterator.next()); assertFalse(iterator.hasNext()); @@ -53,7 +51,7 @@ public class FileLinesByteArrayCollectionTest { a = new byte[] { '0', '\n', '1' }; BinIO.storeBytes(a, file); - flbac = new FileLinesByteArrayCollection(file.toString()); + flbac = new it.unimi.dsi.big.io.FileLinesByteArrayCollection(file.toString()); assertEquals(2, flbac.size64()); iterator = flbac.iterator(); assertArrayEquals(new byte[] { '0' }, iterator.next()); @@ -66,7 +64,7 @@ public class FileLinesByteArrayCollectionTest { a = new byte[1000000]; Arrays.fill(a, (byte)'A'); BinIO.storeBytes(a, file); - flbac = new FileLinesByteArrayCollection(file.toString()); + flbac = new it.unimi.dsi.big.io.FileLinesByteArrayCollection(file.toString()); assertEquals(1, flbac.size64()); iterator = flbac.iterator(); assertArrayEquals(a, iterator.next()); diff --git a/test/it/unimi/dsi/io/FileLinesMutableStringIterableTest.java b/test/it/unimi/dsi/io/FileLinesMutableStringIterableTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5fd3802587975dab39bc5817668f3a3f65b0aa61 --- /dev/null +++ b/test/it/unimi/dsi/io/FileLinesMutableStringIterableTest.java @@ -0,0 +1,99 @@ +/* + * DSI utilities + * + * Copyright (C) 2020-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.io; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.Iterator; +import java.util.List; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +import org.junit.Test; + +import com.google.common.base.Charsets; + +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import it.unimi.dsi.fastutil.objects.ObjectBigLists; +import it.unimi.dsi.io.FileLinesMutableStringIterable.FileLinesIterator; + +public class FileLinesMutableStringIterableTest { + + @Test + public void test() throws IOException, SecurityException { + final File file = File.createTempFile(FastBufferedReaderTest.class.getSimpleName(), "tmp"); + file.deleteOnExit(); + final List<String> l = new ObjectArrayList<>(new String[] { "ciao", "mamma", "guarda" }); + final OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(file), Charsets.US_ASCII); + for (final String s : l) outputStreamWriter.append(s + "\n"); + outputStreamWriter.close(); + + final FileLinesMutableStringIterable fileLinesIterable = new FileLinesMutableStringIterable(file.toString(), Charsets.US_ASCII); + assertEquals(l.size(), fileLinesIterable.size64()); + assertEquals(l.size(), fileLinesIterable.size64()); + final FileLinesIterator iterator = fileLinesIterable.iterator(); + final Iterator<String> listIterator = l.iterator(); + assertEquals(listIterator.next(), iterator.next().toString()); + assertEquals(listIterator.next(), iterator.next().toString()); + assertTrue(iterator.hasNext()); + assertTrue(iterator.hasNext()); + assertEquals(listIterator.next(), iterator.next().toString()); + assertFalse(iterator.hasNext()); + assertFalse(iterator.hasNext()); + assertEquals(l.size(), fileLinesIterable.size64()); + + assertEquals(l, fileLinesIterable.allLines()); + assertEquals(ObjectBigLists.asBigList(new ObjectArrayList<>(l)), fileLinesIterable.allLinesBig()); + } + + @Test + public void testZipped() throws IOException, NoSuchMethodException, SecurityException { + final File file = File.createTempFile(FastBufferedReaderTest.class.getSimpleName(), "tmp"); + file.deleteOnExit(); + final List<String> l = new ObjectArrayList<>(new String[] { "ciao", "mamma", "guarda" }); + final GZIPOutputStream gzipOutputStream = new GZIPOutputStream(new FileOutputStream(file)); + final OutputStreamWriter outputStreamWriter = new OutputStreamWriter(gzipOutputStream, Charsets.US_ASCII); + for(final String s: l) outputStreamWriter.append(s + "\n"); + outputStreamWriter.close(); + + final FileLinesMutableStringIterable fileLinesIterable = new FileLinesMutableStringIterable(file.toString(), Charsets.US_ASCII, GZIPInputStream.class); + assertEquals(l.size(), fileLinesIterable.size64()); + assertEquals(l.size(), fileLinesIterable.size64()); + final FileLinesIterator iterator = fileLinesIterable.iterator(); + final Iterator<String> listIterator = l.iterator(); + assertEquals(listIterator.next(), iterator.next().toString()); + assertEquals(listIterator.next(), iterator.next().toString()); + assertTrue(iterator.hasNext()); + assertTrue(iterator.hasNext()); + assertEquals(listIterator.next(), iterator.next().toString()); + assertFalse(iterator.hasNext()); + assertFalse(iterator.hasNext()); + assertEquals(l.size(), fileLinesIterable.size64()); + + assertEquals(l, fileLinesIterable.allLines()); + assertEquals(ObjectBigLists.asBigList(new ObjectArrayList<>(l)), fileLinesIterable.allLinesBig()); + } +} diff --git a/test/it/unimi/dsi/io/InputBitStreamTest.java b/test/it/unimi/dsi/io/InputBitStreamTest.java index 76b9d962a102d9f051a600e277b841fdd1cf4c00..c6f1806e6332fb306a8e5281fb6663f57cedea53 100644 --- a/test/it/unimi/dsi/io/InputBitStreamTest.java +++ b/test/it/unimi/dsi/io/InputBitStreamTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/test/it/unimi/dsi/io/OfflineIterableTest.java b/test/it/unimi/dsi/io/OfflineIterableTest.java index 6bb4694176d9668ca6153910124b101a2edaf556..0a5bf63e3fbd9c951a97f304eeb292e15eef2652 100644 --- a/test/it/unimi/dsi/io/OfflineIterableTest.java +++ b/test/it/unimi/dsi/io/OfflineIterableTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/test/it/unimi/dsi/io/OutputBitStreamTest.java b/test/it/unimi/dsi/io/OutputBitStreamTest.java index ee91b1dd00e9f6940a2ea032c1ed1de6da7cf309..b12844d967b7db2c5aea13a0d4f107bf20d16189 100644 --- a/test/it/unimi/dsi/io/OutputBitStreamTest.java +++ b/test/it/unimi/dsi/io/OutputBitStreamTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2011-2020 Sebastiano Vigna + * Copyright (C) 2011-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/test/it/unimi/dsi/io/SegmentedInputStreamTest.java b/test/it/unimi/dsi/io/SegmentedInputStreamTest.java index 5996b2270b35a1de98f63b7d110ded696fa03657..2f7fd2391ddf3bcbd22fb692c29debe4b604c4e7 100644 --- a/test/it/unimi/dsi/io/SegmentedInputStreamTest.java +++ b/test/it/unimi/dsi/io/SegmentedInputStreamTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.io; diff --git a/test/it/unimi/dsi/lang/EnumParserTest.java b/test/it/unimi/dsi/lang/EnumParserTest.java index f9dca3e947b111a4f6080b798f6746efa2801a19..176bf7670f74e0a89f95c022550d51ea401365f2 100644 --- a/test/it/unimi/dsi/lang/EnumParserTest.java +++ b/test/it/unimi/dsi/lang/EnumParserTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.lang; diff --git a/test/it/unimi/dsi/lang/MutableStringTest.java b/test/it/unimi/dsi/lang/MutableStringTest.java index 57cebe0ae7d63c899980ca3920a5f4e4919764fb..aae437f7c0c0170a47c83cea404b7e06871cabd6 100644 --- a/test/it/unimi/dsi/lang/MutableStringTest.java +++ b/test/it/unimi/dsi/lang/MutableStringTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.lang; diff --git a/test/it/unimi/dsi/lang/ObjectParserTest.java b/test/it/unimi/dsi/lang/ObjectParserTest.java index fd6fe19bebf47a5872e38a870b0dbaece9f8a198..c685cb90e9b0c950128d895ba722972b1255cb3b 100644 --- a/test/it/unimi/dsi/lang/ObjectParserTest.java +++ b/test/it/unimi/dsi/lang/ObjectParserTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.lang; diff --git a/test/it/unimi/dsi/lang/TwoStrings.java b/test/it/unimi/dsi/lang/TwoStrings.java index 357d0233c8240499b4ca8f8f5d4f13583596bd8f..c4326d2eca028eeec27bd38f100e9135978d9b19 100644 --- a/test/it/unimi/dsi/lang/TwoStrings.java +++ b/test/it/unimi/dsi/lang/TwoStrings.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.lang; diff --git a/test/it/unimi/dsi/parser/BulletParserTest.java b/test/it/unimi/dsi/parser/BulletParserTest.java index f379c41b396118648a3aabee6437661ee65c2f0f..0b83a2226b7cd6e27db5f9295bb23dd1e9189dad 100644 --- a/test/it/unimi/dsi/parser/BulletParserTest.java +++ b/test/it/unimi/dsi/parser/BulletParserTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser; @@ -30,6 +29,7 @@ import java.lang.reflect.Proxy; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; +import org.junit.Ignore; import org.junit.Test; import com.google.common.io.ByteStreams; @@ -38,6 +38,8 @@ import it.unimi.dsi.lang.MutableString; import it.unimi.dsi.parser.callback.Callback; import it.unimi.dsi.parser.callback.DefaultCallback; +@Deprecated +@Ignore public class BulletParserTest { @Test diff --git a/test/it/unimi/dsi/parser/callback/BulletParserCallbackContentHandler.java b/test/it/unimi/dsi/parser/callback/BulletParserCallbackContentHandler.java index 1cf5f94725d1494462ebfbe5e651596647211df5..aad401c6076d4c39129f53933c263ecfd2b2db43 100644 --- a/test/it/unimi/dsi/parser/callback/BulletParserCallbackContentHandler.java +++ b/test/it/unimi/dsi/parser/callback/BulletParserCallbackContentHandler.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser.callback; @@ -39,6 +38,7 @@ import it.unimi.dsi.parser.Element; * actual callback invocations are the same. */ +@Deprecated public class BulletParserCallbackContentHandler extends DefaultHandler { /** The delegated callback. */ private final Callback callback; diff --git a/test/it/unimi/dsi/parser/callback/LinkExtractorTest.java b/test/it/unimi/dsi/parser/callback/LinkExtractorTest.java index 83be45ea9af804a1a1fb5fdd100cef44599bb64d..29830eda0d28466bb4ae488f4d40b36206f78c6a 100644 --- a/test/it/unimi/dsi/parser/callback/LinkExtractorTest.java +++ b/test/it/unimi/dsi/parser/callback/LinkExtractorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser.callback; @@ -26,6 +25,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; +import org.junit.Ignore; import org.junit.Test; import com.google.common.io.ByteStreams; @@ -33,6 +33,8 @@ import com.google.common.io.ByteStreams; import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; import it.unimi.dsi.parser.BulletParser; +@Deprecated +@Ignore public class LinkExtractorTest { @Test diff --git a/test/it/unimi/dsi/parser/callback/TextExtractorTest.java b/test/it/unimi/dsi/parser/callback/TextExtractorTest.java index 691c5d7a2ebddf4a86648468ea6c1f42d46ad166..1a1b9572cfed2091bbe9c9767e56cf9b10323ae2 100644 --- a/test/it/unimi/dsi/parser/callback/TextExtractorTest.java +++ b/test/it/unimi/dsi/parser/callback/TextExtractorTest.java @@ -1,31 +1,33 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.parser.callback; import static org.junit.Assert.assertTrue; +import org.junit.Ignore; import org.junit.Test; import it.unimi.dsi.parser.BulletParser; +@Deprecated +@Ignore public class TextExtractorTest { @Test diff --git a/test/it/unimi/dsi/stat/JackknifeTest.java b/test/it/unimi/dsi/stat/JackknifeTest.java index d75bde4e58d492e6c97877ebd684b68407c6a64e..d762418dbd7765cf438ace3cd01f0c45a0eab8c3 100644 --- a/test/it/unimi/dsi/stat/JackknifeTest.java +++ b/test/it/unimi/dsi/stat/JackknifeTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2011-2020 Sebastiano Vigna + * Copyright (C) 2011-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.stat; diff --git a/test/it/unimi/dsi/stat/SummaryStatsTest.java b/test/it/unimi/dsi/stat/SummaryStatsTest.java index 256c1c61648c40b42ba3672a70019af5c36e7014..0f9243e2fd9d8bf31721e21e36fc92f680005cae 100644 --- a/test/it/unimi/dsi/stat/SummaryStatsTest.java +++ b/test/it/unimi/dsi/stat/SummaryStatsTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2011-2020 Sebastiano Vigna + * Copyright (C) 2011-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.stat; diff --git a/test/it/unimi/dsi/test/XorShiftTest.java b/test/it/unimi/dsi/test/XorShiftTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6cb53a2b8551f3e0fe7883a6d0a57a84f9195e45 --- /dev/null +++ b/test/it/unimi/dsi/test/XorShiftTest.java @@ -0,0 +1,204 @@ +/* + * DSI utilities + * + * Copyright (C) 2011-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ + +package it.unimi.dsi.test; + +import static it.unimi.dsi.test.XorShift.BITS; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.math.BigInteger; +import java.util.Arrays; + +import org.junit.Ignore; +import org.junit.Test; + +@Ignore("Too slow, never changes") +@Deprecated +public class XorShiftTest { + + @Test + public void testMultiply64Bit() { + final it.unimi.dsi.util.XorShift128PlusRandomGenerator random = new it.unimi.dsi.util.XorShift128PlusRandomGenerator(0); + final long[] x = new long[64], y = new long[64], t = new long[64]; + + for(int i = 64; i-- != 0;) { + x[i] = random.nextLong(); + y[i] = random.nextLong(); + } + + for(int i = 64; i-- != 0;) + for(int j = 64; j-- != 0;) + for(int k = 64; k-- != 0;) t[i] ^= ((x[i] & 1L << k) != 0 ? 1L : 0) * ((y[k] & 1L << j) != 0 ? 1L : 0) << j; + + assertArrayEquals(t, XorShift.multiply(x, y)); + + } + + @Test + public void testWord() { + final it.unimi.dsi.util.XorShift128PlusRandomGenerator random = new it.unimi.dsi.util.XorShift128PlusRandomGenerator(0); + final long[][] m = XorShift.newMatrix(BITS); + for(final long[] a : m) for(int i = a.length; i-- != 0;) a[i] = random.nextLong(); + + for(int r = 0; r < BITS - 128; r++) + for(int c = 0; c < BITS / 64; c++) + if (r + 64 < BITS - 64 && c + 1 < 64) assertEquals(XorShift.word(m, r, c, BITS), XorShift.word(m, r + 64, c + 1, BITS)); + } + + //@Ignore + @Test + public void testMultiply() { + final it.unimi.dsi.util.XorShift128PlusRandomGenerator random = new it.unimi.dsi.util.XorShift128PlusRandomGenerator(0); + final long[][] m = XorShift.newMatrix(BITS); + for(int i = 64; i-- != 0;) m[i][BITS / 64 - 1] = random.nextLong(); + for(int i = 64; i-- != 0;) m[BITS - i - 1][BITS / 64 - 1] = random.nextLong(); + for(int i = 64; i-- != 0;) m[BITS - 64 + i][BITS / 64 - 2] = 1L << i; + for(int i = 64; i-- != 0;) m[64 + i][0] = 1L << i; + + long[][] n = m; + + for(int i = 0; i < 4; i++) { + // final long start = - System.nanoTime(); + final long[][] p = XorShift.multiply(m, n); + // System.err.println("Multiplication took " + (System.nanoTime() + start) / 1E9 + "s"); + + for(int r = 0; r < BITS; r++) { + final long t[] = new long[BITS / 64]; + for(int c = 0; c < BITS; c++) + if ((XorShift.word(m, r, c / 64, BITS) & 1L << c) != 0) + for(int w = BITS / 64; w-- != 0;) t[w] ^= XorShift.word(n, c, w, BITS); + + for(int w = BITS / 64; w-- != 0;) assertEquals(t[w], XorShift.word(p, r, w, BITS)); + } + n = p; + } + } + + @Test + public void testIdentity() { + final long[][] identity = XorShift.identity(); + assertTrue(XorShift.isIdentity(identity)); + for(int r = identity.length; r-- != 0;) + for(int c = identity[r].length; c-- != 0;) + for(int b = 64; b-- != 0;) { + identity[r][c] ^= 1L << b; + assertFalse(XorShift.isIdentity(identity)); + identity[r][c] ^= 1L << b; + } + } + + @Test + public void testMPow() { + final it.unimi.dsi.util.XorShift128PlusRandomGenerator random = new it.unimi.dsi.util.XorShift128PlusRandomGenerator(0); + final long[][] m = XorShift.newMatrix(BITS); + for(int i = 64; i-- != 0;) m[i][BITS / 64 - 1] = random.nextLong(); + for(int i = 64; i-- != 0;) m[BITS - i - 1][BITS / 64 - 1] = random.nextLong(); + for(int i = 64; i-- != 0;) m[BITS - 64 + i][BITS / 64 - 2] = 1L << i; + for(int i = 64; i-- != 0;) m[64 + i][0] = 1L << i; + + final long[][][] q = XorShift.quad(m); + + long[][] p = m; + for(int i = 0; i < 12; i++) p = XorShift.multiply(p, m); + + assertTrue(Arrays.deepEquals(p, XorShift.mPow(q, BigInteger.valueOf(13)))); + } + + /** Multiplies the given row vector by the given matrix. + * + * @param v a row vector. + * @param M a matrix. + * @param bits the number of bits in a row. + * @return the row vector {@code vM}. + */ + public static long[] multiply(final long[] v, final long[][] M, final int bits) { + final long[] result = new long[v.length]; + for(int i = v.length; i-- != 0;) + for(int b = 64; b-- != 0;) + if ((v[i] & 1L << b) != 0) + for(int w = v.length; w-- != 0;) result[w] ^= XorShift.word(M, i * 64 + b, w, bits); + + return result; + } + + @Test + public void testMarsagliaVsLoopVsMatrixMultiplication() { + long x = 1, y = 2, z = 3, v = 4, t; + final long[] s = { 4, 1, 2, 3 }; + long[] ss = { 1, 2, 3, 4 }; + final int a = 5, b = 18, c = 12; // Random + final long[][] m = XorShift.makeABCMatrix(a, b, c, 256); + int p = 0; + for(int i = 0; i < 1000; i++) { + // Marsaglia + t = (x ^ (x << a)); + //System.err.println("t: " + t); + x = y; + y = z; + z = v; + v = (v ^ (v >>> c)) ^ (t ^ (t >>> b)); + + // Our loop + final long s0 = s[p]; + long s1 = s[p = (p + 1) & 3]; + s1 ^= s1 << a; + s[p] = s1 ^ s0 ^ (s1 >>> b) ^ (s0 >>> c); + + assertEquals(Integer.toString(i), v, s[p]); + + // Matrix multiplication + ss = multiply(ss, m, 256); + + assertEquals(Integer.toString(i), x, ss[0]); + assertEquals(Integer.toString(i), y, ss[1]); + assertEquals(Integer.toString(i), z, ss[2]); + assertEquals(Integer.toString(i), v, ss[3]); + + assertEquals(Integer.toString(i), x, s[p + 1 & 3]); + assertEquals(Integer.toString(i), y, s[p + 2 & 3]); + assertEquals(Integer.toString(i), z, s[p + 3 & 3]); + assertEquals(Integer.toString(i), v, s[p]); + } + } + + @Test + public void test128SwitchVsMatrixMultiplication() { + final long[] s = { 1, 2 }; + long[] ss = { 1, 2 }; + final int a = 5, b = 18, c = 12; // Random + final long[][] m = XorShift.makeABCMatrix(a, b, c, 128); + for(int i = 0; i < 1000; i++) { + // Our loop + long s1 = s[0]; + final long s0 = s[1]; + s[0] = s0; + s1 ^= s1 << a; + s[1] = (s1 ^ s0 ^ (s1 >>> b) ^ (s0 >>> c)); + + // Matrix multiplication + ss = multiply(ss, m, 128); + + assertEquals(Integer.toString(i), ss[0], s[0]); + assertEquals(Integer.toString(i), ss[1], s[1]); + } + } +} diff --git a/test/it/unimi/dsi/util/BloomFilterTest.java b/test/it/unimi/dsi/util/BloomFilterTest.java index 9a7a6d238122e2d7e400424b9b6b993535512085..c7b0d15e751064e8118106857ddbb32f489db766 100644 --- a/test/it/unimi/dsi/util/BloomFilterTest.java +++ b/test/it/unimi/dsi/util/BloomFilterTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/ByteBufferLongBigListTest.java b/test/it/unimi/dsi/util/ByteBufferLongBigListTest.java index 9d9a6b4354801547054c5ce0115050d608173f8f..4d9b5e71c6d1c85864b875bf769ba9ceb1b81747 100644 --- a/test/it/unimi/dsi/util/ByteBufferLongBigListTest.java +++ b/test/it/unimi/dsi/util/ByteBufferLongBigListTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/CircularCharArrayBufferTest.java b/test/it/unimi/dsi/util/CircularCharArrayBufferTest.java index 5b31975b05da786e4daaf8dbc644646e8d4056a1..1b6246a15e3391e897666e86b8c87515c172eddd 100644 --- a/test/it/unimi/dsi/util/CircularCharArrayBufferTest.java +++ b/test/it/unimi/dsi/util/CircularCharArrayBufferTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/FrontCodedStringListTest.java b/test/it/unimi/dsi/util/FrontCodedStringListTest.java index ccea8fe158a379f71d46dd2bb23078d8fea75371..d421dc353bedb566a8fefa254d16edfceab526c5 100644 --- a/test/it/unimi/dsi/util/FrontCodedStringListTest.java +++ b/test/it/unimi/dsi/util/FrontCodedStringListTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/HyperLogLogCounterArrayTest.java b/test/it/unimi/dsi/util/HyperLogLogCounterArrayTest.java index 5f7cec4d760a506db44d4906ce728437f589a832..1ce94e97e45cb5802823d6e68c9d621ed4e0488a 100644 --- a/test/it/unimi/dsi/util/HyperLogLogCounterArrayTest.java +++ b/test/it/unimi/dsi/util/HyperLogLogCounterArrayTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Paolo Boldi and Sebastiano Vigna + * Copyright (C) 2010-2021 Paolo Boldi and Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/ImmutableBinaryTrieTest.java b/test/it/unimi/dsi/util/ImmutableBinaryTrieTest.java index 45e5746beb963561fb316c899ffdb70367be152d..26e78ecf14cfec02db303e83441a4a8aaf8ff16c 100644 --- a/test/it/unimi/dsi/util/ImmutableBinaryTrieTest.java +++ b/test/it/unimi/dsi/util/ImmutableBinaryTrieTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/ImmutableExternalPrefixMapTest.java b/test/it/unimi/dsi/util/ImmutableExternalPrefixMapTest.java index 40104571f38bb893f49ef50b7b324814ffba36da..6d033ff4efd5b8e456637200244304b5dd23d72f 100644 --- a/test/it/unimi/dsi/util/ImmutableExternalPrefixMapTest.java +++ b/test/it/unimi/dsi/util/ImmutableExternalPrefixMapTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/IntervalTest.java b/test/it/unimi/dsi/util/IntervalTest.java index 440c7d25d885f2f1052da2df2773f542e8ed57da..6cea303feeb8257919e119f462f28d5c15b24845 100644 --- a/test/it/unimi/dsi/util/IntervalTest.java +++ b/test/it/unimi/dsi/util/IntervalTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/KahanSummationTest.java b/test/it/unimi/dsi/util/KahanSummationTest.java index 6f07cada959946dee34292e2b07710068ea7453b..24a7f9d90ef9bbe3df7a43476598ebdd34495a6e 100644 --- a/test/it/unimi/dsi/util/KahanSummationTest.java +++ b/test/it/unimi/dsi/util/KahanSummationTest.java @@ -1,19 +1,20 @@ /* - * Copyright (C) 2011-2020 Sebastiano Vigna + * DSI utilities * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * Copyright (C) 2011-2021 Sebastiano Vigna * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/LineIteratorTest.java b/test/it/unimi/dsi/util/LineIteratorTest.java index b55ce776d2959cb4070e066ce373e2e0601c8f7f..478abdd464f62a6fb5828de840e45f62e3703a78 100644 --- a/test/it/unimi/dsi/util/LineIteratorTest.java +++ b/test/it/unimi/dsi/util/LineIteratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/LiterallySignedStringMapTest.java b/test/it/unimi/dsi/util/LiterallySignedStringMapTest.java index 42af0ae3d6a13856c78c60567849cc8995719202..9f83c5c4cad07c4f1943336b1e046f4da66fbdea 100644 --- a/test/it/unimi/dsi/util/LiterallySignedStringMapTest.java +++ b/test/it/unimi/dsi/util/LiterallySignedStringMapTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/LongIntervalTest.java b/test/it/unimi/dsi/util/LongIntervalTest.java index 52db9d95c669515fcece240f35f08105449f3519..1d655d65924b351b48620d826ff0edb974d72983 100644 --- a/test/it/unimi/dsi/util/LongIntervalTest.java +++ b/test/it/unimi/dsi/util/LongIntervalTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/SemiExternalGammaListTest.java b/test/it/unimi/dsi/util/SemiExternalGammaListTest.java index 0550fea4948a19c7c47c0acf89a231a47ea6a011..8c6cd0be5449f6c060552ceffb36c1d9f1a4545a 100644 --- a/test/it/unimi/dsi/util/SemiExternalGammaListTest.java +++ b/test/it/unimi/dsi/util/SemiExternalGammaListTest.java @@ -1,22 +1,21 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - * - */ + * Copyright (C) 2010-2021 Sebastiano Vigna + * + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. + * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 + */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/ShiftAddXorSignedStringMapTest.java b/test/it/unimi/dsi/util/ShiftAddXorSignedStringMapTest.java index e35098180a5695c0756560b3da355ee271259878..3126a6eec9e785fc78006bfe7f9cf771f292af73 100644 --- a/test/it/unimi/dsi/util/ShiftAddXorSignedStringMapTest.java +++ b/test/it/unimi/dsi/util/ShiftAddXorSignedStringMapTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/SplitMix64RandomGeneratorTest.java b/test/it/unimi/dsi/util/SplitMix64RandomGeneratorTest.java index bf762f39b7ef5e541903a720f0039f8cdf2924bc..f5173c12723c2e49388e1b7950c0b876addb94e5 100644 --- a/test/it/unimi/dsi/util/SplitMix64RandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/SplitMix64RandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2015-2020 Sebastiano Vigna + * Copyright (C) 2015-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/SplitMix64RandomTest.java b/test/it/unimi/dsi/util/SplitMix64RandomTest.java index 26e060acee9834fd45b2544e8efbec23662f09f0..94111a0ae5e25f3d25250f346a3266f286c019d7 100644 --- a/test/it/unimi/dsi/util/SplitMix64RandomTest.java +++ b/test/it/unimi/dsi/util/SplitMix64RandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2015-2020 Sebastiano Vigna + * Copyright (C) 2015-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/TernaryIntervalSearchTreeTest.java b/test/it/unimi/dsi/util/TernaryIntervalSearchTreeTest.java index fa73da849e8aa7ec24b9d15f656f15c0e2b0b046..8fb31b514d0f16d068486297ab95dd191a200086 100644 --- a/test/it/unimi/dsi/util/TernaryIntervalSearchTreeTest.java +++ b/test/it/unimi/dsi/util/TernaryIntervalSearchTreeTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/TextPatternTest.java b/test/it/unimi/dsi/util/TextPatternTest.java index 2791d7a2f479479acd67d6ed42cd285e6659cbfc..64f9a5569e1cca5eb026fc30f56bcba09775b369 100644 --- a/test/it/unimi/dsi/util/TextPatternTest.java +++ b/test/it/unimi/dsi/util/TextPatternTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2010-2020 Sebastiano Vigna + * Copyright (C) 2010-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomGeneratorTest.java b/test/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomGeneratorTest.java index bc98704efbd4db8df5948069880deaf7a4acc132..3aa93766df98e5588dc48efc01265e9dbc85f948 100644 --- a/test/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomTest.java b/test/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomTest.java index 71042ee36fe5829bc8d05125cbf94fe1691a0499..ab55d5fc8e41e9ec126225026c1688455afa7532 100644 --- a/test/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomTest.java +++ b/test/it/unimi/dsi/util/XoRoShiRo128PlusPlusRandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoRoShiRo128PlusRandomGeneratorTest.java b/test/it/unimi/dsi/util/XoRoShiRo128PlusRandomGeneratorTest.java index d5012050838584d4f24a161056af38726c22d3fc..f166551553cae4125580dfa9aa07f0fa105d3fee 100644 --- a/test/it/unimi/dsi/util/XoRoShiRo128PlusRandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/XoRoShiRo128PlusRandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoRoShiRo128PlusRandomTest.java b/test/it/unimi/dsi/util/XoRoShiRo128PlusRandomTest.java index 5281ac1072e9c8a4ae6d5b6188dcb3719f03a1dc..5e17d54c84caba53f11a662dfaabbbc04c32ddf8 100644 --- a/test/it/unimi/dsi/util/XoRoShiRo128PlusRandomTest.java +++ b/test/it/unimi/dsi/util/XoRoShiRo128PlusRandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoRoShiRo128StarStarRandomGeneratorTest.java b/test/it/unimi/dsi/util/XoRoShiRo128StarStarRandomGeneratorTest.java index c35c5ff0e0a08e12307517efe656c69ea0cc2e07..60d3fb368244e3151a4b62a0d015217142b82bc4 100644 --- a/test/it/unimi/dsi/util/XoRoShiRo128StarStarRandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/XoRoShiRo128StarStarRandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoRoShiRo128StarStarRandomTest.java b/test/it/unimi/dsi/util/XoRoShiRo128StarStarRandomTest.java index ee18943622b04f757f6326496b15483bfc1b3239..b6eb215931efa8ae66082154ffea08342d739422 100644 --- a/test/it/unimi/dsi/util/XoRoShiRo128StarStarRandomTest.java +++ b/test/it/unimi/dsi/util/XoRoShiRo128StarStarRandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoShiRo256PlusPlusRandomGeneratorTest.java b/test/it/unimi/dsi/util/XoShiRo256PlusPlusRandomGeneratorTest.java index deb68fc416043c64026015a09dc15b6e5ec860a4..510c3e057562611f6d9feb87b9155aba29a9f121 100644 --- a/test/it/unimi/dsi/util/XoShiRo256PlusPlusRandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/XoShiRo256PlusPlusRandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoShiRo256PlusPlusRandomTest.java b/test/it/unimi/dsi/util/XoShiRo256PlusPlusRandomTest.java index c3a4b064d2c724877748eff61e678b3dea58d476..174079e5b4ea857273d9ff25f8ba51e3c83b0208 100644 --- a/test/it/unimi/dsi/util/XoShiRo256PlusPlusRandomTest.java +++ b/test/it/unimi/dsi/util/XoShiRo256PlusPlusRandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoShiRo256PlusRandomGeneratorTest.java b/test/it/unimi/dsi/util/XoShiRo256PlusRandomGeneratorTest.java index 6dda30591e2bf2211a17826a1140eea63acbeace..543a1dfdfb6b6459466a5596161eb1328fc17e2d 100644 --- a/test/it/unimi/dsi/util/XoShiRo256PlusRandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/XoShiRo256PlusRandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoShiRo256PlusRandomTest.java b/test/it/unimi/dsi/util/XoShiRo256PlusRandomTest.java index 658de4d4365907b6366221561bd71a28ef577351..575c343ab27eb69c2e776925ad73dea0ac870645 100644 --- a/test/it/unimi/dsi/util/XoShiRo256PlusRandomTest.java +++ b/test/it/unimi/dsi/util/XoShiRo256PlusRandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoShiRo256StarStarRandomGeneratorTest.java b/test/it/unimi/dsi/util/XoShiRo256StarStarRandomGeneratorTest.java index 7ed64435a275b7c033c7da8a5b945591bff1df83..32b26c095bf61bf447888127be39abf49f9cb771 100644 --- a/test/it/unimi/dsi/util/XoShiRo256StarStarRandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/XoShiRo256StarStarRandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XoShiRo256StarStarRandomTest.java b/test/it/unimi/dsi/util/XoShiRo256StarStarRandomTest.java index e35ceb042409a3430354fb2d765f811a574721a5..b3a22b062e6d1fd37315b7ecd965b595cbb188c9 100644 --- a/test/it/unimi/dsi/util/XoShiRo256StarStarRandomTest.java +++ b/test/it/unimi/dsi/util/XoShiRo256StarStarRandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XorShift1024StarPhiRandomGeneratorTest.java b/test/it/unimi/dsi/util/XorShift1024StarPhiRandomGeneratorTest.java index 5630b551cc6576e71e41b4e7c2d171f5973f59cd..149c767915889e98aea38b0b7868ba290c996985 100644 --- a/test/it/unimi/dsi/util/XorShift1024StarPhiRandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/XorShift1024StarPhiRandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XorShift1024StarPhiRandomTest.java b/test/it/unimi/dsi/util/XorShift1024StarPhiRandomTest.java index eec6c818d73f7bea93812cedb2d6d19546cf327a..b078eefe919f56129f3ea2766c9ea1b37fe2ff9d 100644 --- a/test/it/unimi/dsi/util/XorShift1024StarPhiRandomTest.java +++ b/test/it/unimi/dsi/util/XorShift1024StarPhiRandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XorShift1024StarRandomGeneratorTest.java b/test/it/unimi/dsi/util/XorShift1024StarRandomGeneratorTest.java index b1d6078ba4fe34b2ce34be634bb6c61dc52cf2c9..7eb07b8b43be250ef3fbcbf7cf62f9c81d02546e 100644 --- a/test/it/unimi/dsi/util/XorShift1024StarRandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/XorShift1024StarRandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XorShift1024StarRandomTest.java b/test/it/unimi/dsi/util/XorShift1024StarRandomTest.java index bb02a0b8451a90d90dd7c4b2792cddc4e92902e5..2885ba849449128b46026f04193861ad22bcf685 100644 --- a/test/it/unimi/dsi/util/XorShift1024StarRandomTest.java +++ b/test/it/unimi/dsi/util/XorShift1024StarRandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2013-2020 Sebastiano Vigna + * Copyright (C) 2013-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XorShift128PlusRandomGeneratorTest.java b/test/it/unimi/dsi/util/XorShift128PlusRandomGeneratorTest.java index cb11575c1de65a55cd9066f0e155dca335399315..d4c7fd31bf726bc989d26edae3f113f2440dbdb2 100644 --- a/test/it/unimi/dsi/util/XorShift128PlusRandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/XorShift128PlusRandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XorShift128PlusRandomTest.java b/test/it/unimi/dsi/util/XorShift128PlusRandomTest.java index b16a5ddb318b410a24fcf3778d0d31d9ba1f03a1..9442b0f512fbe0b987a2f76da5c7d6bd200a9539 100644 --- a/test/it/unimi/dsi/util/XorShift128PlusRandomTest.java +++ b/test/it/unimi/dsi/util/XorShift128PlusRandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2014-2020 Sebastiano Vigna + * Copyright (C) 2014-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XorShift64StarRandomGeneratorTest.java b/test/it/unimi/dsi/util/XorShift64StarRandomGeneratorTest.java index e2a39d718c178c6020209f499448259ac4f7853b..a855a464712109a2057beeda6bc4d06215a1e58c 100644 --- a/test/it/unimi/dsi/util/XorShift64StarRandomGeneratorTest.java +++ b/test/it/unimi/dsi/util/XorShift64StarRandomGeneratorTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2012-2020 Sebastiano Vigna + * Copyright (C) 2012-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/XorShift64StarRandomTest.java b/test/it/unimi/dsi/util/XorShift64StarRandomTest.java index f6175c048fb9507a71a66e6216f44bbcdf9ccbe6..7527dbf31387c645f48990c1a22cb49296964d6f 100644 --- a/test/it/unimi/dsi/util/XorShift64StarRandomTest.java +++ b/test/it/unimi/dsi/util/XorShift64StarRandomTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2012-2020 Sebastiano Vigna + * Copyright (C) 2012-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util; diff --git a/test/it/unimi/dsi/util/concurrent/ReorderingBlockingQueueTest.java b/test/it/unimi/dsi/util/concurrent/ReorderingBlockingQueueTest.java index 67755606aec5af2b3bf27eb2014cf797ce3e0a84..1f4eb90d3624e8a6081727cbbdc4f157b3ab1abc 100644 --- a/test/it/unimi/dsi/util/concurrent/ReorderingBlockingQueueTest.java +++ b/test/it/unimi/dsi/util/concurrent/ReorderingBlockingQueueTest.java @@ -1,21 +1,20 @@ /* * DSI utilities * - * Copyright (C) 2017-2020 Sebastiano Vigna + * Copyright (C) 2017-2021 Sebastiano Vigna * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. + * This program and the accompanying materials are made available under the + * terms of the GNU Lesser General Public License v2.1 or later, + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html, + * or the Apache Software License 2.0, which is available at + * https://www.apache.org/licenses/LICENSE-2.0. * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. * + * SPDX-License-Identifier: LGPL-2.1-or-later OR Apache-2.0 */ package it.unimi.dsi.util.concurrent;