
2010-10-12 Andrew John Hughes <ahughes@redhat.com> Import GNU Classpath (libgcj-snapshot-20100921). * libjava/Makefile.in: Regenerated. * libjava/javax/swing/text/html/StyleSheet.h, * libjava/javax/swing/text/html/MinimalHTMLWriter.h, * libjava/javax/swing/text/html/HTMLWriter.h, * libjava/javax/xml/stream/XMLEventFactory.h, * libjava/javax/xml/stream/XMLOutputFactory.h, * libjava/javax/xml/stream/events/Namespace.h, * libjava/javax/xml/stream/util/StreamReaderDelegate.h, * libjava/javax/security/auth/kerberos/KeyImpl.h, * libjava/javax/security/auth/kerberos/KerberosTicket.h: Regenerated. * libjava/classpath/Makefile.in, * libjava/classpath/depcomp, * libjava/classpath/scripts/Makefile.in, * libjava/classpath/resource/Makefile.in, * libjava/classpath/tools/Makefile.in: Regenerated. Use libtool from top-level config directory. * libjava/classpath/tools/classes/gnu/classpath/tools/StringToolkit.class, * libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml.class, * libjava/classpath/tools/classes/gnu/classpath/tools/java2xhtml/Java2xhtml$State.class, * libjava/classpath/tools/classes/gnu/classpath/tools/IOToolkit.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$3.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$5.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$7.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$9.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$OptionProcessor.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportClassFile.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$21.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TagImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocProxy.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$23.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BlockSourceComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree$FileNode.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$25.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/IgnoredFileParseException.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TextTagImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$Context.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/InheritDocTagImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FunctionComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AdditionExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Type.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NegateExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantDouble.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/EqualExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantChar.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Evaluator.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/DivisionExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantInteger.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantShort.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantLong.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantByte.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnaryExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantFloat.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ModuloExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantString.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/AndExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/Context.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantNull.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/LessThanExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/BinaryExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/expr/ConstantExpression.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportNotFound.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParamTagImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Timer.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourceComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/CommentComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionPackage.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/StaticBlockComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ValueTagImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SeeTagImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$11.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$13.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ConstructorDocImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$15.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TemporaryStore.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportReflectionClass.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$17.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/BracketClose.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$19.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParameterImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ScheduledClass.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl$ResolvedImportPackageFile.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$2.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SlashSlashCommentComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ErrorReporter.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$4.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$6.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MemberDocImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$8.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser$1.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DirectoryTree.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Debug.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/DocImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/MethodDocImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$20.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/FieldDocImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/RootDocImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$22.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$24.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TimerDoclet$1.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/PackageDocImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ThrowsTagImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/EmptyStatementComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/LinkTagImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/AbstractTagImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ParseException.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$10.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$12.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Parser.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Whitespace.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$14.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/ImportComponent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$16.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$18.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/SourcePositionImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/JavadocWrapper.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/Main$1.class, * libjava/classpath/tools/classes/gnu/classpath/tools/gjdoc/TypeVariableImpl.class, * libjava/classpath/tools/classes/gnu/classpath/tools/NotifyingInputStreamReader.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/GcjhMain.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniStubPrinter.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniIncludePrinter.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/PathOptionGroup.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/JniPrintStream.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/Main.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.class, * libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$3.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/HashFinder.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$4.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$5.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler$MethodRef.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/WrapUnWrapper.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$6.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$7.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$8.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$9.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Generator.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/GiopIo.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/MethodGenerator.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RmiMethodGenerator.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/SourceRmicCompiler.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Variables.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/ClassRmicCompiler.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/CompilationError.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$10.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$11.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$12.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$13.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$14.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$15.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$16.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$17.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$18.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/RMICException.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$1.class, * libjava/classpath/tools/classes/gnu/classpath/tools/rmic/Main$2.class, * libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer.class, * libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$1.class, * libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$2.class, * libjava/classpath/tools/classes/gnu/classpath/tools/serialver/SerialVer$3.class, * libjava/classpath/tools/classes/gnu/classpath/tools/MalformedInputEvent.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletConfigurationException.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$InterfaceRelation.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTag.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/TargetContext.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet$DocErrorReporterOutputStream.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$1.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$UsageType.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/Driver$NullErrorReporter.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer$TagInfo.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionColonSeparated.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTaglet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$UsageType.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionString.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/CssClass.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$1.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$2.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$3.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet$TreeNode.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/InvalidPackageWildcardException.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFlag.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageMatcher.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/StandardTaglet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOptionFile.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/DocletOption.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$IndexKey.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionGroup.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/AbstractDoclet$DocletOptionTagletPath.class, * libjava/classpath/tools/classes/gnu/classpath/tools/doclets/PackageGroup.class, * libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$JarStreamInfo.class, * libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader$FileStreamInfo.class, * libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CodeTaglet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/taglets/GenericTaglet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/taglets/ValueTaglet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet$EmailReplacement.class, * libjava/classpath/tools/classes/gnu/classpath/tools/taglets/DeprecatedTaglet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/taglets/SinceTaglet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/taglets/AuthorTaglet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/taglets/TagletContext.class, * libjava/classpath/tools/classes/gnu/classpath/tools/taglets/VersionTaglet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/taglets/CopyrightTaglet.class, * libjava/classpath/tools/classes/gnu/classpath/tools/FileSystemClassLoader.class, * libjava/classpath/tools/classes/com/sun/tools/javadoc/Main.class: Regenerated. * libjava/classpath/doc/Makefile.in, * libjava/classpath/doc/api/Makefile.in, * libjava/classpath/doc/texinfo.tex, * libjava/classpath/external/Makefile.in, * libjava/classpath/external/jsr166/Makefile.in, * libjava/classpath/external/sax/Makefile.in, * libjava/classpath/external/w3c_dom/Makefile.in, * libjava/classpath/external/relaxngDatatype/Makefile.in, * libjava/classpath/include/Makefile.in: Regenerated. * libjava/classpath/m4/lib-prefix.m4, * libjava/classpath/m4/lib-link.m4, * libjava/classpath/m4/lib-ld.m4: Removed. * libjava/classpath/native/jni/classpath/Makefile.in, * libjava/classpath/native/jni/gstreamer-peer/Makefile.in, * libjava/classpath/native/jni/midi-dssi/Makefile.in, * libjava/classpath/native/jni/Makefile.in, * libjava/classpath/native/jni/gconf-peer/Makefile.in, * libjava/classpath/native/jni/java-io/Makefile.in, * libjava/classpath/native/jni/native-lib/Makefile.in, * libjava/classpath/native/jni/native-lib/cpnet.c, * libjava/classpath/native/jni/java-util/Makefile.in, * libjava/classpath/native/jni/java-lang/Makefile.in, * libjava/classpath/native/jni/midi-alsa/Makefile.in, * libjava/classpath/native/jni/java-nio/Makefile.in, * libjava/classpath/native/jni/java-net/Makefile.in, * libjava/classpath/native/jni/java-math/Makefile.in, * libjava/classpath/native/jni/xmlj/Makefile.in, * libjava/classpath/native/jni/qt-peer/Makefile.in, * libjava/classpath/native/jni/gtk-peer/Makefile.in, * libjava/classpath/native/Makefile.in, * libjava/classpath/native/jawt/Makefile.in, * libjava/classpath/native/fdlibm/Makefile.in, * libjava/classpath/native/plugin/Makefile.in, * libjava/classpath/lib/java/util/regex/Matcher.class, * libjava/classpath/lib/java/util/TreeMap$3.class, * libjava/classpath/lib/java/util/Scanner.class, * libjava/classpath/lib/Makefile.in, * libjava/classpath/lib/org/omg/PortableServer/_ServantActivatorStub.class, * libjava/classpath/lib/org/omg/PortableServer/_ServantLocatorStub.class, * libjava/classpath/lib/org/omg/CORBA/portable/InputStream.class, * libjava/classpath/lib/org/omg/CORBA/portable/ObjectImpl.class, * libjava/classpath/lib/org/omg/CORBA/portable/Delegate.class, * libjava/classpath/lib/org/omg/CORBA/LocalObject.class, * libjava/classpath/lib/org/omg/CORBA_2_3/portable/InputStream.class, * libjava/classpath/lib/org/omg/CORBA_2_3/portable/OutputStream.class, * libjava/classpath/lib/org/omg/DynamicAny/_DynSequenceStub.class, * libjava/classpath/lib/org/omg/DynamicAny/_DynValueStub.class, * libjava/classpath/lib/org/omg/DynamicAny/_DynStructStub.class, * libjava/classpath/lib/org/omg/DynamicAny/_DynEnumStub.class, * libjava/classpath/lib/org/omg/DynamicAny/_DynArrayStub.class, * libjava/classpath/lib/org/omg/DynamicAny/_DynAnyFactoryStub.class, * libjava/classpath/lib/org/omg/DynamicAny/_DynAnyStub.class, * libjava/classpath/lib/org/omg/DynamicAny/_DynUnionStub.class, * libjava/classpath/lib/org/omg/DynamicAny/_DynFixedStub.class, * libjava/classpath/lib/org/ietf/jgss/GSSManager.class, * libjava/classpath/lib/gnu/xml/stream/NamespaceImpl.class, * libjava/classpath/lib/gnu/xml/stream/XIncludeFilter.class, * libjava/classpath/lib/gnu/xml/stream/FilteredStreamReader.class, * libjava/classpath/lib/gnu/xml/stream/XMLEventFactoryImpl.class, * libjava/classpath/lib/gnu/xml/stream/XMLEventAllocatorImpl.class, * libjava/classpath/lib/gnu/xml/stream/XMLStreamWriterImpl.class, * libjava/classpath/lib/gnu/java/locale/LocaleData.class, * libjava/classpath/lib/gnu/javax/swing/text/html/css/Selector.class, * libjava/classpath/lib/gnu/javax/print/ipp/IppRequest$RequestWriter.class, * libjava/classpath/lib/gnu/javax/print/ipp/IppResponse$ResponseReader.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/printer/CharsetConfigured.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/printer/DocumentFormat.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/printer/PrinterUpTime.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/SidesSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/PageRangesSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/MediaSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/OperationsSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/CharsetSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/FinishingsSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/CompressionSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/SidesDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/MediaDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/CopiesDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/UnknownAttribute.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/DetailedStatusMessage.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/job/JobPrinterUri.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/job/AttributesCharset.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/job/JobStateMessage.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/job/JobId.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/job/JobMoreInfo.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/job/JobUri.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/RequestedAttributes.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/StatusMessage.class, * libjava/classpath/lib/gnu/javax/print/ipp/attribute/DocumentAccessError.class, * libjava/classpath/lib/gnu/javax/print/ipp/IppUtilities.class, * libjava/classpath/lib/gnu/javax/print/ipp/IppPrintService.class, * libjava/classpath/lib/gnu/javax/print/ipp/IppResponse.class, * libjava/classpath/lib/javax/swing/tree/DefaultMutableTreeNode.class, * libjava/classpath/lib/javax/swing/tree/VariableHeightLayoutCache.class, * libjava/classpath/lib/javax/swing/tree/DefaultMutableTreeNode$PostorderEnumeration.class, * libjava/classpath/lib/javax/swing/tree/DefaultMutableTreeNode$BreadthFirstEnumeration.class, * libjava/classpath/lib/javax/swing/tree/DefaultMutableTreeNode$PreorderEnumeration.class, * libjava/classpath/lib/javax/swing/tree/FixedHeightLayoutCache.class, * libjava/classpath/lib/javax/swing/text/html/HTMLEditorKit.class, * libjava/classpath/lib/javax/swing/text/html/StyleSheet$BoxPainter.class, * libjava/classpath/lib/javax/swing/text/html/HTMLWriter.class, * libjava/classpath/lib/javax/swing/text/html/TableView$RowView.class, * libjava/classpath/lib/javax/swing/text/html/MultiAttributeSet$MultiNameEnumeration.class, * libjava/classpath/lib/javax/swing/text/html/MultiStyle.class, * libjava/classpath/lib/javax/swing/text/html/ImageView.class, * libjava/classpath/lib/javax/swing/text/html/TableView$CellView.class, * libjava/classpath/lib/javax/swing/text/html/MultiAttributeSet.class, * libjava/classpath/lib/javax/swing/text/html/ImageView$1.class, * libjava/classpath/lib/javax/swing/text/html/StyleSheet$ListPainter.class, * libjava/classpath/lib/javax/swing/text/html/TableView.class, * libjava/classpath/lib/javax/swing/text/html/StyleSheet.class, * libjava/classpath/lib/javax/swing/text/html/ObjectView.class, * libjava/classpath/lib/javax/swing/text/html/MinimalHTMLWriter.class, * libjava/classpath/lib/javax/swing/undo/UndoableEditSupport.class, * libjava/classpath/lib/javax/swing/undo/StateEdit.class, * libjava/classpath/lib/javax/xml/stream/XMLEventFactory.class, * libjava/classpath/lib/javax/xml/stream/events/Namespace.class, * libjava/classpath/lib/javax/xml/stream/XMLInputFactory.class, * libjava/classpath/lib/javax/xml/stream/util/StreamReaderDelegate.class, * libjava/classpath/lib/javax/xml/stream/XMLOutputFactory.class, * libjava/classpath/lib/javax/security/auth/kerberos/KerberosTicket.class, * libjava/classpath/lib/javax/security/auth/kerberos/KeyImpl.class, * libjava/classpath/missing, * libjava/classpath/aclocal.m4, * libjava/classpath/examples/Makefile.in, * libjava/classpath/install-sh, * libjava/gnu/xml/stream/FilteredStreamReader.h, * libjava/gnu/xml/stream/XMLStreamWriterImpl.h, * libjava/gnu/xml/stream/NamespaceImpl.h, * libjava/gnu/xml/stream/XIncludeFilter.h, * libjava/gnu/javax/swing/text/html/css/Selector.h, * libjava/gnu/javax/print/ipp/attribute/RequestedAttributes.h, * libjava/sources.am: Regenerated. 2010-05-27 Andrew John Hughes <ahughes@redhat.com> * configure.ac: Disable plugin by default and warn about unmaintained status when enabled. 2010-05-04 Andrew John Hughes <ahughes@redhat.com> * configure.ac: Call AC_PROG_JAVA_WORKS and AC_PROG_JAVAC_WORKS in place of AC_PROG_JAVA and AC_PROG_JAVAC respectively, as this is the real test we want. * m4/ac_prog_java.m4: (AC_PROG_JAVA): Don't include AC_PROG_JAVA_WORKS. * m4/ac_prog_java_works.m4: (AC_PROG_JAVA_WORKS): Require AC_PROG_JAVA and be defined only once. Require AC_PROG_JAVAC_WORKS for compilation of test class. Remove inclusion of AC_PROG_JAVAC. (AC_TRY_COMPILE_JAVA): Require AC_PROG_JAVAC_WORKS rather than AC_PROG_JAVAC. Be defined only once. * m4/ac_prog_javac.m: (AC_PROG_JAVAC): Be defined only once. Don't include AC_PROG_JAVAC_WORKS. * m4/ac_prog_javac_works.m4: (AC_PROG_JAVAC_WORKS): Be defined only once. Require AC_PROG_JAVAC. 2010-05-04 Andrew Haley <aph@redhat.com> * lib/gen-classlist.sh.in: Use absolute pathnames for all the directory names in the output file. 2010-05-04 Andrew John Hughes <ahughes@redhat.com> * m4/ac_prog_javac.m4: Capture all output from javac --version to avoid excess output. Make sure no appears when javac is not gcj. 2010-05-04 Andrew John Hughes <ahughes@redhat.com> * configure.ac: Add output to GMP directory detection and only perform when compiling GMP. 2010-05-04 Mike Stump <mikestump@comcast.net> * configure.ac: Allow prefix, libdir and includedir of GMP to be specified via --with-gmp, --with-gmp-include and --with-gmp-lib. 2010-04-28 Andrew John Hughes <ahughes@redhat.com> * gnu/javax/print/ipp/IppPrintService.java: (printerAttr): Add generic typing. (printServiceAttributeListener): Likewise. (flavors): Likewise. (printerUris): Likewise. (IppPrintService(URI uri, String username, String password)): Use generic types in initialising listener set. (getPrinterAttributes()): Add generic types. Remove cast. (getPrinterAttributeSet(Class<T>)): Return a set containing attributes of type T. Now creates a new set and checks that all elements of the original set can be cast and added to this new set. (getPrinterDefaultAttribute(Class<? extends Attribute>)): Add generic types. (processResponse()): Add generic types. (getAttribute(Class<T>)): Use generic types corresponding to parent interface. (getSupportedAttributeCategories()): Use generic types. (getSupportedAttributeValues()): Likewise. (handleSupportedAttributeValuesResponse(IppResponse,Class<? extends Attribute>)): Likewise. (isAttributeCategorySupported(Class<? extends Attribute>)): Likewise. * gnu/javax/print/ipp/IppResponse.java: (parseResponse(InputStream)): Use generic types. (parseAttributes(Map<Class<? extends Attribute>, Set<Attribute>, DataInputStream)): Likewise. (addAttribute(Map<Class<? extends Attribute>, Set<Attribute>>, Attribute): Likewise. (IppResponse(URI, short)): Create lists with appropriate type parameters. (getJobAttributes()): Use generic return type. (getOperationAttributes()): Likewise. (getPrinterAttributes()): Likewise. (getUnsupportedAttributes()): Likewise. * gnu/javax/print/ipp/attribute/supported/CompressionSupported.java: (getAssociatedAttributeArray(Set<Attribute>)): Use superclass Attribute as set type parameter and cast when looping over it. * gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java, (getAssociatedAttributeArray(Set<Attribute>)): Use superclass Attribute as set type parameter and cast when looping over it. * gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java, (getAssociatedAttributeArray(Set<Attribute>)): Use superclass Attribute as set type parameter and cast when looping over it. * gnu/javax/print/ipp/attribute/supported/MediaSupported.java, (getAssociatedAttributeArray(Set<Attribute>)): Use superclass Attribute as set type parameter and cast when looping over it. * gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java, (getAssociatedAttributeArray(Set<Attribute>)): Use superclass Attribute as set type parameter and cast when looping over it. * gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java, (getAssociatedAttributeArray(Set<Attribute>)): Use superclass Attribute as set type parameter and cast when looping over it. * gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java, (getAssociatedAttributeArray(Set<Attribute>)): Use superclass Attribute as set type parameter and cast when looping over it. * gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java, (getAssociatedAttributeArray(Set<Attribute>)): Use superclass Attribute as set type parameter and cast when looping over it. 2010-04-28 Andrew John Hughes <ahughes@redhat.com> * gnu/javax/print/ipp/IppUtilities.java: (INTEGER_CLASS_ARRAY): Use generic typing. (TEXT_CLASS_ARRAY): Likewise. (classesByName): Likewise. (instanceByClass): Likewise. (getClass(String)): Remove cast. Return generic type. (getSupportedAttrName(Class<? extends Attribute>)): Remove cast. Add generic type to parameter. (getSupportedCategory(Class<?> extends Attribute>)): Likewise. (getEnumAttribute(String,Object)): Add missing generic types on Class. (getIntegerAttribute(String,int)): Likewise and on Constructor. (getTextAttribute(String,byte,byte[])): Likewise. 2010-04-27 Andrew John Hughes <ahughes@redhat.com> * gnu/javax/print/ipp/IppRequest.java: (write(RequestedAttributes)): Fix for change in return value of RequestedAttributes.getValues(). * gnu/javax/print/ipp/attribute/DetailedStatusMessage.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/DocumentAccessError.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/RequestedAttributes.java: (RequestedAttributes()): Use appropriate generic type with attributes ArrayList. (getValues()): Return an array-based snapshot of the current state of attributes rather than providing direct mutable access to it. * gnu/javax/print/ipp/attribute/StatusMessage.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/UnknownAttribute.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/MediaDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/defaults/SidesDefault.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/job/AttributesCharset.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/job/JobId.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/job/JobMoreInfo.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/job/JobPrinterUri.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/job/JobStateMessage.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/job/JobUri.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/printer/DocumentFormat.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java: (getCategory()): Fix return value. * gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java: (getCategory()): Fix return value. 2010-04-27 Andrew John Hughes <ahughes@redhat.com> * gnu/javax/print/CupsIppOperation.java, * gnu/javax/print/CupsMediaMapping.java, * gnu/javax/print/CupsPrintService.java, * gnu/javax/print/CupsPrintServiceLookup.java, * gnu/javax/print/CupsServer.java, * gnu/javax/print/PrintAttributeException.java, * gnu/javax/print/PrintFlavorException.java, * gnu/javax/print/PrintUriException.java, * gnu/javax/print/PrinterDialog.java, * gnu/javax/print/ipp/DocPrintJobImpl.java, * gnu/javax/print/ipp/IppDelimiterTag.java, * gnu/javax/print/ipp/IppException.java, * gnu/javax/print/ipp/IppMultiDocPrintService.java, * gnu/javax/print/ipp/IppRequest.java, * gnu/javax/print/ipp/IppResponse.java, * gnu/javax/print/ipp/IppStatusCode.java, * gnu/javax/print/ipp/IppUtilities.java, * gnu/javax/print/ipp/IppValueTag.java, * gnu/javax/print/ipp/MultiDocPrintJobImpl.java, * gnu/javax/print/ipp/attribute/CharsetSyntax.java, * gnu/javax/print/ipp/attribute/DefaultValueAttribute.java, * gnu/javax/print/ipp/attribute/DetailedStatusMessage.java, * gnu/javax/print/ipp/attribute/DocumentAccessError.java, * gnu/javax/print/ipp/attribute/NaturalLanguageSyntax.java, * gnu/javax/print/ipp/attribute/RequestedAttributes.java, * gnu/javax/print/ipp/attribute/StatusMessage.java, * gnu/javax/print/ipp/attribute/UnknownAttribute.java, * gnu/javax/print/ipp/attribute/defaults/CopiesDefault.java, * gnu/javax/print/ipp/attribute/defaults/DocumentFormatDefault.java, * gnu/javax/print/ipp/attribute/defaults/FinishingsDefault.java, * gnu/javax/print/ipp/attribute/defaults/JobHoldUntilDefault.java, * gnu/javax/print/ipp/attribute/defaults/JobPriorityDefault.java, * gnu/javax/print/ipp/attribute/defaults/JobSheetsDefault.java, * gnu/javax/print/ipp/attribute/defaults/MediaDefault.java, * gnu/javax/print/ipp/attribute/defaults/MultipleDocumentHandlingDefault.java, * gnu/javax/print/ipp/attribute/defaults/NumberUpDefault.java, * gnu/javax/print/ipp/attribute/defaults/OrientationRequestedDefault.java, * gnu/javax/print/ipp/attribute/defaults/PrintQualityDefault.java, * gnu/javax/print/ipp/attribute/defaults/PrinterResolutionDefault.java, * gnu/javax/print/ipp/attribute/defaults/SidesDefault.java, * gnu/javax/print/ipp/attribute/job/AttributesCharset.java, * gnu/javax/print/ipp/attribute/job/AttributesNaturalLanguage.java, * gnu/javax/print/ipp/attribute/job/JobDetailedStatusMessages.java, * gnu/javax/print/ipp/attribute/job/JobDocumentAccessErrors.java, * gnu/javax/print/ipp/attribute/job/JobId.java, * gnu/javax/print/ipp/attribute/job/JobMoreInfo.java, * gnu/javax/print/ipp/attribute/job/JobPrinterUri.java, * gnu/javax/print/ipp/attribute/job/JobStateMessage.java, * gnu/javax/print/ipp/attribute/job/JobUri.java, * gnu/javax/print/ipp/attribute/printer/CharsetConfigured.java, * gnu/javax/print/ipp/attribute/printer/DocumentFormat.java, * gnu/javax/print/ipp/attribute/printer/MultipleOperationTimeOut.java, * gnu/javax/print/ipp/attribute/printer/NaturalLanguageConfigured.java, * gnu/javax/print/ipp/attribute/printer/PrinterCurrentTime.java, * gnu/javax/print/ipp/attribute/printer/PrinterDriverInstaller.java, * gnu/javax/print/ipp/attribute/printer/PrinterStateMessage.java, * gnu/javax/print/ipp/attribute/printer/PrinterUpTime.java: Normalise whitespace; replace tabs with spaces and removing trailing whitespace. 2010-04-27 Andrew John Hughes <ahughes@redhat.com> * gnu/javax/print/ipp/IppPrintService.java: Fix whitespace. Use correct generic type for printerAttr map. (getPrinterAttributeSet(Class<? extends Attribute>)): Add appropriate generic type. * gnu/javax/print/ipp/attribute/supported/CharsetSupported.java: Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/CompressionSupported.java: Fix whitespace. (getCategory()): Fix return type. (getAssociatedAttributeArray(Set<CompressionSupported>)): Add generic type to set and use for-each loop. * gnu/javax/print/ipp/attribute/supported/DocumentFormatSupported.java: Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/FinishingsSupported.java: Fix whitespace. (getCategory()): Fix return type. (getAssociatedAttributeArray(Set<FinishingsSupported>)): Add generic type to set and use for-each loop. * gnu/javax/print/ipp/attribute/supported/GeneratedNaturalLanguageSupported.java: Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/IppVersionsSupported.java: Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/JobHoldUntilSupported.java: Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/JobSheetsSupported.java: Fix whitespace. (getCategory()): Fix return type. (getAssociatedAttributeArray(Set<JobSheetsSupported>)): Add generic type to set and use for-each loop. * gnu/javax/print/ipp/attribute/supported/MediaSupported.java: Fix whitespace. (getCategory()): Fix return type. (getAssociatedAttributeArray(Set<MediaSupported>)): Add generic type to set and use for-each loop. * gnu/javax/print/ipp/attribute/supported/MultipleDocumentHandlingSupported.java: Fix whitespace. (getCategory()): Fix return type. (getAssociatedAttributeArray(Set<MultipleDocumentHandlingSupported>)): Add generic type to set and use for-each loop. * gnu/javax/print/ipp/attribute/supported/MultipleDocumentJobsSupported.java, Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/OperationsSupported.java, Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/OrientationRequestedSupported.java, Fix whitespace. (getCategory()): Fix return type. (getAssociatedAttributeArray(Set<OrientationRequestedSupported>)): Add generic type to set and use for-each loop. * gnu/javax/print/ipp/attribute/supported/PageRangesSupported.java, Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/PrintQualitySupported.java, Fix whitespace. (getCategory()): Fix return type. (getAssociatedAttributeArray(Set<PrintQualitySupported>)): Add generic type to set and use for-each loop. * gnu/javax/print/ipp/attribute/supported/PrinterResolutionSupported.java, Fix whitespace. (getCategory()): Fix return type. (getAssociatedAttributeArray(Set<PrinterResolutionSupported>)): Add generic type to set and use for-each loop. * gnu/javax/print/ipp/attribute/supported/PrinterUriSupported.java, Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/SidesSupported.java, Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/UriAuthenticationSupported.java, Fix whitespace. (getCategory()): Fix return type. * gnu/javax/print/ipp/attribute/supported/UriSecuritySupported.java, Fix whitespace. (getCategory()): Fix return type. 2010-04-27 Andrew Haley <aph@redhat.com> * java/util/concurrent/CopyOnWriteArrayList.java: Fix for empty list. 2010-04-27 Andrew Haley <aph@redhat.com> * gnu/javax/print/ipp/IppResponse.java (parseAttributes): Handle IppValueTag.UNKNOWN. * gnu/javax/print/ipp/IppRequest.java (writeOperationAttributes): Handle RequestedAttributes. * gnu/javax/print/ipp/IppPrintService.java (processResponse): Add DocFlavor.SERVICE_FORMATTED.PAGEABLE and DocFlavor.SERVICE_FORMATTED.PRINTABLE. 2010-03-01 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> PR libgcj/38251 * tools/Makefile.am (dist-hook): Prune .svn directories in asm and classes copies. * tools/Makefile.in: Regenerate. Revert: 2008-11-05 Andrew Haley <aph@redhat.com> * tools/Makefile.am (UPDATE_TOOLS_ZIP, CREATE_TOOLS_ZIP): Exclude .svn direcories. 2010-01-30 Andrew John Hughes <ahughes@redhat.com> * doc/www.gnu.org/home.wml: Add newer JAPI results. 2010-01-30 Andrew John Hughes <ahughes@redhat.com> PR classpath/41686 * javax/security/auth/kerberos/KerberosTicket.java: Fix formatting. (toString()): Add full implementation. (getSessionKeyType()): Implemented. * javax/security/auth/kerberos/KeyImpl.java: (toString()): Implemented. 2010-01-30 Andrew John Hughes <ahughes@redhat.com> * autogen.sh: Allow libtool 2.* through. * configure.ac: Updated via autoupdate. * m4/lib-ld.m4, * m4/lib-link.m4, * m4/lib-prefix.m4: Drop old libtool macros which result in build failure. 2010-01-18 Andreas Tobler <andreast@fgznet.ch> * tools/Makefile.am (GJDOC_EX): Use find -name pattern -prune -o. * tools/Makefile.in: Regenerate. 2010-01-12 Jeroen Frijters <jeroen@frijters.net> * java/util/zip/Inflater. java (inflate(byte[],int,int)): Fix for #41696. 2009-11-18 Andrew Haley <aph@redhat.com> * java/util/TreeMap.java (anonymous class.size()): Debogosify. anonymous class.clear(): Likewise. 2009-10-22 Andrew Haley <aph@redhat.com> * native/jni/native-lib/cpnet.c (cpnet_addMembership): Fix aliasing warning. (cpnet_dropMembership): Likewise. 2009-10-22 Richard Guenther <rguenther@suse.de> PR cp-tools/39177 * tools/gnu/classpath/tools/jar/Creator.java (writeCommandLineEntries): Do not use uninitialized manifest. * tools/classes/gnu/classpath/tools/jar/Creator.class: Re-generated. 2009-07-08 Chris Burdess <dog@gnu.org> PR xml/40663: * javax/xml/stream/XMLEventFactory.java, * javax/xml/stream/XMLInputFactory.java, * javax/xml/stream/XMLOutputFactory.java, * javax/xml/stream/events/Namespace.java: Update API to match final version of StAX. * javax/xml/stream/util/ReaderDelegate.java: Removed. * javax/xml/stream/util/StreamReaderDelegate.java: Added (renamed from ReaderDelegate) * gnu/xml/stream/FilteredStreamReader.java, * gnu/xml/stream/NamespaceImpl.java, * gnu/xml/stream/XIncludeFilter.java, * gnu/xml/stream/XMLEventAllocatorImpl.java, * gnu/xml/stream/XMLEventFactoryImpl.java: Update implementation to match final version of StAX API. 2009-07-06 Ludovic Claude <ludovic.claude@laposte.net> PR xml/40653: * gnu/xml/stream/XMLStreamWriterImpl.java: Weaken testing of namespace prefix to match reference implementation and spec. 2009-07-07 Andrew John Hughes <ahughes@redhat.com> PR classpath/40630 * java/util/Scanner.java: (myCoreNext(boolean, Pattern)): Set tmp2 to null if the string is empty (i.e. we are at the end of the file). * java/util/regex/Matcher.java: (toMatchResult()): Check that match is non-null before attempting to clone it. 2009-07-07 Andrew John Hughes <ahughes@redhat.com> * java/util/Scanner.java, * java/util/regex/Matcher.java: Replace tab characters with spaces. 2009-03-29 Mark Wielaard <mark@klomp.org> * doc/www.gnu.org/faq/faq.wml: Fix link to cp-hacking.html. 2009-03-29 Mark Wielaard <mark@klomp.org> * m4/ac_prog_antlr.m4: Check whether ANTLR_JAR is empty. 2009-03-26 Andrew John Hughes <ahughes@redhat.com> PR classpath/39408: * tools/gnu/classpath/tools/javah/ClassWrapper.java: (linkSupers()): Make package-private. * tools/gnu/classpath/tools/javah/JniIncludePrinter.java: (writeFields(ClassWrapper, JniPrintStream)): Link in data from superclass before searching for fields. 2009-03-20 Andrew John Hughes <ahughes@redhat.com> * tools/gnu/classpath/tools/javah/ClassWrapper.java, * tools/gnu/classpath/tools/javah/CniPrintStream.java, * tools/gnu/classpath/tools/javah/CniStubPrinter.java, * tools/gnu/classpath/tools/javah/GcjhMain.java, * tools/gnu/classpath/tools/javah/JniIncludePrinter.java, * tools/gnu/classpath/tools/javah/JniPrintStream.java, * tools/gnu/classpath/tools/javah/JniStubPrinter.java, * tools/gnu/classpath/tools/javah/Keywords.java, * tools/gnu/classpath/tools/javah/Main.java, * tools/gnu/classpath/tools/javah/MethodHelper.java, * tools/gnu/classpath/tools/javah/PathOptionGroup.java: Fix generic issues in gjavah. 2009-03-17 Andrew John Hughes <ahughes@redhat.com> * tools/gnu/classpath/tools/FileSystemClassLoader.java, * tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java, * tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java, * tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java, * tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java, * tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java, * tools/gnu/classpath/tools/gjdoc/ErrorReporter.java, * tools/gnu/classpath/tools/gjdoc/TemporaryStore.java, * tools/gnu/classpath/tools/gjdoc/WritableType.java, * tools/gnu/classpath/tools/taglets/AuthorTaglet.java, * tools/gnu/classpath/tools/taglets/CopyrightTaglet.java, * tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java, * tools/gnu/classpath/tools/taglets/GenericTaglet.java, * tools/gnu/classpath/tools/taglets/SinceTaglet.java, * tools/gnu/classpath/tools/taglets/VersionTaglet.java: Switch to UNIX line endings. 2009-03-17 Andrew John Hughes <ahughes@redhat.com> * tools/com/sun/tools/javadoc/Main.java, * tools/gnu/classpath/tools/FileSystemClassLoader.java, * tools/gnu/classpath/tools/IOToolkit.java, * tools/gnu/classpath/tools/MalformedInputEvent.java, * tools/gnu/classpath/tools/MalformedInputListener.java, * tools/gnu/classpath/tools/NotifyingInputStreamReader.java, * tools/gnu/classpath/tools/StringToolkit.java, * tools/gnu/classpath/tools/doclets/AbstractDoclet.java, * tools/gnu/classpath/tools/doclets/DocletConfigurationException.java, * tools/gnu/classpath/tools/doclets/DocletOption.java, * tools/gnu/classpath/tools/doclets/DocletOptionColonSeparated.java, * tools/gnu/classpath/tools/doclets/DocletOptionFile.java, * tools/gnu/classpath/tools/doclets/DocletOptionFlag.java, * tools/gnu/classpath/tools/doclets/DocletOptionPackageWildcard.java, * tools/gnu/classpath/tools/doclets/DocletOptionString.java, * tools/gnu/classpath/tools/doclets/InlineTagRenderer.java, * tools/gnu/classpath/tools/doclets/InvalidPackageWildcardException.java, * tools/gnu/classpath/tools/doclets/PackageGroup.java, * tools/gnu/classpath/tools/doclets/PackageMatcher.java, * tools/gnu/classpath/tools/doclets/StandardTaglet.java, * tools/gnu/classpath/tools/doclets/TagletPrinter.java, * tools/gnu/classpath/tools/doclets/debugdoclet/DebugDoclet.java, * tools/gnu/classpath/tools/doclets/htmldoclet/CssClass.java, * tools/gnu/classpath/tools/doclets/htmldoclet/ExternalDocSet.java, * tools/gnu/classpath/tools/doclets/htmldoclet/HtmlDoclet.java, * tools/gnu/classpath/tools/doclets/htmldoclet/HtmlPage.java, * tools/gnu/classpath/tools/doclets/htmldoclet/HtmlTagletContext.java, * tools/gnu/classpath/tools/doclets/xmldoclet/Driver.java, * tools/gnu/classpath/tools/doclets/xmldoclet/Driver1_4.java, * tools/gnu/classpath/tools/doclets/xmldoclet/HtmlRepairer.java, * tools/gnu/classpath/tools/doclets/xmldoclet/TargetContext.java, * tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTranslet.java, * tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletConfigurationException.java, * tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletException.java, * tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/DocTransletOptions.java, * tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/JarClassLoader.java, * tools/gnu/classpath/tools/doclets/xmldoclet/doctranslet/OutputFileInfo.java, * tools/gnu/classpath/tools/gjdoc/AbstractTagImpl.java, * tools/gnu/classpath/tools/gjdoc/ArrayCharacterIterator.java, * tools/gnu/classpath/tools/gjdoc/ClassDocImpl.java, * tools/gnu/classpath/tools/gjdoc/ClassDocProxy.java, * tools/gnu/classpath/tools/gjdoc/ClassDocReflectedImpl.java, * tools/gnu/classpath/tools/gjdoc/ConstructorDocImpl.java, * tools/gnu/classpath/tools/gjdoc/Debug.java, * tools/gnu/classpath/tools/gjdoc/DirectoryTree.java, * tools/gnu/classpath/tools/gjdoc/DocImpl.java, * tools/gnu/classpath/tools/gjdoc/ErrorReporter.java, * tools/gnu/classpath/tools/gjdoc/ExecutableMemberDocImpl.java, * tools/gnu/classpath/tools/gjdoc/FieldDocImpl.java, * tools/gnu/classpath/tools/gjdoc/GjdocPackageDoc.java, * tools/gnu/classpath/tools/gjdoc/GjdocRootDoc.java, * tools/gnu/classpath/tools/gjdoc/InheritDocTagImpl.java, * tools/gnu/classpath/tools/gjdoc/JavadocWrapper.java, * tools/gnu/classpath/tools/gjdoc/LinkTagImpl.java, * tools/gnu/classpath/tools/gjdoc/Main.java, * tools/gnu/classpath/tools/gjdoc/MemberDocImpl.java, * tools/gnu/classpath/tools/gjdoc/MethodDocImpl.java, * tools/gnu/classpath/tools/gjdoc/PackageDocImpl.java, * tools/gnu/classpath/tools/gjdoc/ParamTagImpl.java, * tools/gnu/classpath/tools/gjdoc/ParameterImpl.java, * tools/gnu/classpath/tools/gjdoc/ParseException.java, * tools/gnu/classpath/tools/gjdoc/Parser.java, * tools/gnu/classpath/tools/gjdoc/ProgramElementDocImpl.java, * tools/gnu/classpath/tools/gjdoc/RootDocImpl.java, * tools/gnu/classpath/tools/gjdoc/SeeTagImpl.java, * tools/gnu/classpath/tools/gjdoc/SerialFieldTagImpl.java, * tools/gnu/classpath/tools/gjdoc/SourcePositionImpl.java, * tools/gnu/classpath/tools/gjdoc/TagContainer.java, * tools/gnu/classpath/tools/gjdoc/TagImpl.java, * tools/gnu/classpath/tools/gjdoc/TemporaryStore.java, * tools/gnu/classpath/tools/gjdoc/TextTagImpl.java, * tools/gnu/classpath/tools/gjdoc/ThrowsTagImpl.java, * tools/gnu/classpath/tools/gjdoc/Timer.java, * tools/gnu/classpath/tools/gjdoc/TimerDoclet.java, * tools/gnu/classpath/tools/gjdoc/TypeImpl.java, * tools/gnu/classpath/tools/gjdoc/TypeVariableImpl.java, * tools/gnu/classpath/tools/gjdoc/ValueTagImpl.java, * tools/gnu/classpath/tools/gjdoc/WritableType.java, * tools/gnu/classpath/tools/gjdoc/expr/AdditionExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/AndExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/BinaryBitwiseExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/BinaryComputationExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/BinaryEqualityExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/BinaryExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/BinaryLogicalExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/BinaryRelationExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/BinaryShiftExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/BitShiftRightExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/CircularExpressionException.java, * tools/gnu/classpath/tools/gjdoc/expr/ConditionalExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantBoolean.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantByte.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantChar.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantDouble.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantFloat.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantInteger.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantLong.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantNull.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantShort.java, * tools/gnu/classpath/tools/gjdoc/expr/ConstantString.java, * tools/gnu/classpath/tools/gjdoc/expr/Context.java, * tools/gnu/classpath/tools/gjdoc/expr/DivisionExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/EqualExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/Evaluator.java, * tools/gnu/classpath/tools/gjdoc/expr/EvaluatorEnvironment.java, * tools/gnu/classpath/tools/gjdoc/expr/ExclusiveOrExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/Expression.java, * tools/gnu/classpath/tools/gjdoc/expr/GreaterThanExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/GreaterThanOrEqualExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/IdentifierExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/IllegalExpressionException.java, * tools/gnu/classpath/tools/gjdoc/expr/InclusiveOrExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/LessThanExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/LessThanOrEqualExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/LogicalAndExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/LogicalNotExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/LogicalOrExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/ModuloExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/MultiplicationExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/NegateExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/NotEqualExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/NotExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/ShiftLeftExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/ShiftRightExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/SubtractionExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/Type.java, * tools/gnu/classpath/tools/gjdoc/expr/TypeCastExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/UnaryExpression.java, * tools/gnu/classpath/tools/gjdoc/expr/UnknownIdentifierException.java, * tools/gnu/classpath/tools/java2xhtml/Java2xhtml.java, * tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java, * tools/gnu/classpath/tools/rmic/CompilationError.java, * tools/gnu/classpath/tools/rmic/Generator.java, * tools/gnu/classpath/tools/rmic/GiopIo.java, * tools/gnu/classpath/tools/rmic/HashFinder.java, * tools/gnu/classpath/tools/rmic/Main.java, * tools/gnu/classpath/tools/rmic/MethodGenerator.java, * tools/gnu/classpath/tools/rmic/RMICException.java, * tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java, * tools/gnu/classpath/tools/rmic/RmicBackend.java, * tools/gnu/classpath/tools/rmic/SourceRmicCompiler.java, * tools/gnu/classpath/tools/rmic/Variables.java, * tools/gnu/classpath/tools/rmic/WrapUnWrapper.java, * tools/gnu/classpath/tools/serialver/SerialVer.java, * tools/gnu/classpath/tools/taglets/AuthorTaglet.java, * tools/gnu/classpath/tools/taglets/CodeTaglet.java, * tools/gnu/classpath/tools/taglets/CopyrightTaglet.java, * tools/gnu/classpath/tools/taglets/DeprecatedTaglet.java, * tools/gnu/classpath/tools/taglets/GenericTaglet.java, * tools/gnu/classpath/tools/taglets/GnuExtendedTaglet.java, * tools/gnu/classpath/tools/taglets/SinceTaglet.java, * tools/gnu/classpath/tools/taglets/TagletContext.java, * tools/gnu/classpath/tools/taglets/ValueTaglet.java, * tools/gnu/classpath/tools/taglets/VersionTaglet.java: Fix license headers to GPLv2+Classpath exception. 2009-03-09 Andrew John Hughes <ahughes@redhat.com> * gnu/javax/swing/text/html/css/Selector.java: Use CPStringBuilder. Use typed list of maps rather than an array for type safety. * javax/swing/text/html/HTMLEditorKit.java, * javax/swing/text/html/HTMLWriter.java: Add generic typing where appropriate. * javax/swing/text/html/ImageView.java: Remove unused AttributeSet variables. * javax/swing/text/html/MinimalHTMLWriter.java: Switch to an ArrayDeque to avoid unnecessary internal synchronisation on a private variable. Add generic typing. * javax/swing/text/html/MultiAttributeSet.java: Add generic typing. * javax/swing/text/html/MultiStyle.java: Add generic typing, make class package-private as not part of the standard classes. * javax/swing/text/html/ObjectView.java, * javax/swing/text/html/StyleSheet.java: Add generic typing. * javax/swing/text/html/TableView.java: Remove unused variable. * javax/swing/tree/DefaultMutableTreeNode.java: Add generic typing, mute warnings where necessary. * javax/swing/tree/FixedHeightLayoutCache.java: Add generic typing. * javax/swing/tree/TreeNode.java: Mute warnings where necessary. * javax/swing/tree/VariableHeightLayoutCache.java, * javax/swing/undo/StateEdit.java, * javax/swing/undo/UndoableEditSupport.java, * org/ietf/jgss/GSSManager.java: Add generic typing. 2009-02-14 Andrew John Hughes <ahughes@redhat.com> * org/omg/CORBA/LocalObject.java, * org/omg/CORBA/portable/Delegate.java, * org/omg/CORBA/portable/InputStream.java, * org/omg/CORBA/portable/ObjectImpl.java, * org/omg/CORBA_2_3/portable/InputStream.java, * org/omg/CORBA_2_3/portable/OutputStream.java, * org/omg/DynamicAny/_DynAnyFactoryStub.java, * org/omg/DynamicAny/_DynAnyStub.java, * org/omg/DynamicAny/_DynArrayStub.java, * org/omg/DynamicAny/_DynEnumStub.java, * org/omg/DynamicAny/_DynFixedStub.java, * org/omg/DynamicAny/_DynSequenceStub.java, * org/omg/DynamicAny/_DynStructStub.java, * org/omg/DynamicAny/_DynUnionStub.java, * org/omg/DynamicAny/_DynValueStub.java, * org/omg/PortableServer/_ServantActivatorStub.java, * org/omg/PortableServer/_ServantLocatorStub.java: Turn off warnings where Class is used; forced to use raw type for API compatibility. 2009-02-06 Andrew John Hughes <ahughes@redhat.com> * NEWS: Add stub for 0.99. * configure.ac: Bump to 0.99. * doc/www.gnu.org/announce/20090205.wml, * doc/www.gnu.org/downloads/downloads.wml, * doc/www.gnu.org/newsitems.txt: Update website. 2009-02-05 Andrew John Hughes <ahughes@redhat.com> * NEWS: Add VM updates. From-SVN: r165383
3322 lines
88 KiB
Java
3322 lines
88 KiB
Java
/* TreeMap.java -- a class providing a basic Red-Black Tree data structure,
|
|
mapping Object --> Object
|
|
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
|
|
|
|
This file is part of GNU Classpath.
|
|
|
|
GNU Classpath 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 2, or (at your option)
|
|
any later version.
|
|
|
|
GNU Classpath is distributed in 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 GNU Classpath; see the file COPYING. If not, write to the
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
02110-1301 USA.
|
|
|
|
Linking this library statically or dynamically with other modules is
|
|
making a combined work based on this library. Thus, the terms and
|
|
conditions of the GNU General Public License cover the whole
|
|
combination.
|
|
|
|
As a special exception, the copyright holders of this library give you
|
|
permission to link this library with independent modules to produce an
|
|
executable, regardless of the license terms of these independent
|
|
modules, and to copy and distribute the resulting executable under
|
|
terms of your choice, provided that you also meet, for each linked
|
|
independent module, the terms and conditions of the license of that
|
|
module. An independent module is a module which is not derived from
|
|
or based on this library. If you modify this library, you may extend
|
|
this exception to your version of the library, but you are not
|
|
obligated to do so. If you do not wish to do so, delete this
|
|
exception statement from your version. */
|
|
|
|
|
|
package java.util;
|
|
|
|
import gnu.java.lang.CPStringBuilder;
|
|
|
|
import java.io.IOException;
|
|
import java.io.ObjectInputStream;
|
|
import java.io.ObjectOutputStream;
|
|
import java.io.Serializable;
|
|
|
|
/**
|
|
* This class provides a red-black tree implementation of the SortedMap
|
|
* interface. Elements in the Map will be sorted by either a user-provided
|
|
* Comparator object, or by the natural ordering of the keys.
|
|
*
|
|
* The algorithms are adopted from Corman, Leiserson, and Rivest's
|
|
* <i>Introduction to Algorithms.</i> TreeMap guarantees O(log n)
|
|
* insertion and deletion of elements. That being said, there is a large
|
|
* enough constant coefficient in front of that "log n" (overhead involved
|
|
* in keeping the tree balanced), that TreeMap may not be the best choice
|
|
* for small collections. If something is already sorted, you may want to
|
|
* just use a LinkedHashMap to maintain the order while providing O(1) access.
|
|
*
|
|
* TreeMap is a part of the JDK1.2 Collections API. Null keys are allowed
|
|
* only if a Comparator is used which can deal with them; natural ordering
|
|
* cannot cope with null. Null values are always allowed. Note that the
|
|
* ordering must be <i>consistent with equals</i> to correctly implement
|
|
* the Map interface. If this condition is violated, the map is still
|
|
* well-behaved, but you may have suprising results when comparing it to
|
|
* other maps.<p>
|
|
*
|
|
* This implementation is not synchronized. If you need to share this between
|
|
* multiple threads, do something like:<br>
|
|
* <code>SortedMap m
|
|
* = Collections.synchronizedSortedMap(new TreeMap(...));</code><p>
|
|
*
|
|
* The iterators are <i>fail-fast</i>, meaning that any structural
|
|
* modification, except for <code>remove()</code> called on the iterator
|
|
* itself, cause the iterator to throw a
|
|
* <code>ConcurrentModificationException</code> rather than exhibit
|
|
* non-deterministic behavior.
|
|
*
|
|
* @author Jon Zeppieri
|
|
* @author Bryce McKinlay
|
|
* @author Eric Blake (ebb9@email.byu.edu)
|
|
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
|
* @see Map
|
|
* @see HashMap
|
|
* @see Hashtable
|
|
* @see LinkedHashMap
|
|
* @see Comparable
|
|
* @see Comparator
|
|
* @see Collection
|
|
* @see Collections#synchronizedSortedMap(SortedMap)
|
|
* @since 1.2
|
|
* @status updated to 1.6
|
|
*/
|
|
public class TreeMap<K, V> extends AbstractMap<K, V>
|
|
implements NavigableMap<K, V>, Cloneable, Serializable
|
|
{
|
|
// Implementation note:
|
|
// A red-black tree is a binary search tree with the additional properties
|
|
// that all paths to a leaf node visit the same number of black nodes,
|
|
// and no red node has red children. To avoid some null-pointer checks,
|
|
// we use the special node nil which is always black, has no relatives,
|
|
// and has key and value of null (but is not equal to a mapping of null).
|
|
|
|
/**
|
|
* Compatible with JDK 1.2.
|
|
*/
|
|
private static final long serialVersionUID = 919286545866124006L;
|
|
|
|
/**
|
|
* Color status of a node. Package visible for use by nested classes.
|
|
*/
|
|
static final int RED = -1,
|
|
BLACK = 1;
|
|
|
|
/**
|
|
* Sentinal node, used to avoid null checks for corner cases and make the
|
|
* delete rebalance code simpler. The rebalance code must never assign
|
|
* the parent, left, or right of nil, but may safely reassign the color
|
|
* to be black. This object must never be used as a key in a TreeMap, or
|
|
* it will break bounds checking of a SubMap.
|
|
*/
|
|
static final Node nil = new Node(null, null, BLACK);
|
|
static
|
|
{
|
|
// Nil is self-referential, so we must initialize it after creation.
|
|
nil.parent = nil;
|
|
nil.left = nil;
|
|
nil.right = nil;
|
|
}
|
|
|
|
/**
|
|
* The root node of this TreeMap.
|
|
*/
|
|
private transient Node root;
|
|
|
|
/**
|
|
* The size of this TreeMap. Package visible for use by nested classes.
|
|
*/
|
|
transient int size;
|
|
|
|
/**
|
|
* The cache for {@link #entrySet()}.
|
|
*/
|
|
private transient Set<Map.Entry<K,V>> entries;
|
|
|
|
/**
|
|
* The cache for {@link #descendingMap()}.
|
|
*/
|
|
private transient NavigableMap<K,V> descendingMap;
|
|
|
|
/**
|
|
* The cache for {@link #navigableKeySet()}.
|
|
*/
|
|
private transient NavigableSet<K> nKeys;
|
|
|
|
/**
|
|
* Counts the number of modifications this TreeMap has undergone, used
|
|
* by Iterators to know when to throw ConcurrentModificationExceptions.
|
|
* Package visible for use by nested classes.
|
|
*/
|
|
transient int modCount;
|
|
|
|
/**
|
|
* This TreeMap's comparator, or null for natural ordering.
|
|
* Package visible for use by nested classes.
|
|
* @serial the comparator ordering this tree, or null
|
|
*/
|
|
final Comparator<? super K> comparator;
|
|
|
|
/**
|
|
* Class to represent an entry in the tree. Holds a single key-value pair,
|
|
* plus pointers to parent and child nodes.
|
|
*
|
|
* @author Eric Blake (ebb9@email.byu.edu)
|
|
*/
|
|
private static final class Node<K, V> extends AbstractMap.SimpleEntry<K, V>
|
|
{
|
|
// All fields package visible for use by nested classes.
|
|
/** The color of this node. */
|
|
int color;
|
|
|
|
/** The left child node. */
|
|
Node<K, V> left = nil;
|
|
/** The right child node. */
|
|
Node<K, V> right = nil;
|
|
/** The parent node. */
|
|
Node<K, V> parent = nil;
|
|
|
|
/**
|
|
* Simple constructor.
|
|
* @param key the key
|
|
* @param value the value
|
|
*/
|
|
Node(K key, V value, int color)
|
|
{
|
|
super(key, value);
|
|
this.color = color;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Instantiate a new TreeMap with no elements, using the keys' natural
|
|
* ordering to sort. All entries in the map must have a key which implements
|
|
* Comparable, and which are <i>mutually comparable</i>, otherwise map
|
|
* operations may throw a {@link ClassCastException}. Attempts to use
|
|
* a null key will throw a {@link NullPointerException}.
|
|
*
|
|
* @see Comparable
|
|
*/
|
|
public TreeMap()
|
|
{
|
|
this((Comparator) null);
|
|
}
|
|
|
|
/**
|
|
* Instantiate a new TreeMap with no elements, using the provided comparator
|
|
* to sort. All entries in the map must have keys which are mutually
|
|
* comparable by the Comparator, otherwise map operations may throw a
|
|
* {@link ClassCastException}.
|
|
*
|
|
* @param c the sort order for the keys of this map, or null
|
|
* for the natural order
|
|
*/
|
|
public TreeMap(Comparator<? super K> c)
|
|
{
|
|
comparator = c;
|
|
fabricateTree(0);
|
|
}
|
|
|
|
/**
|
|
* Instantiate a new TreeMap, initializing it with all of the elements in
|
|
* the provided Map. The elements will be sorted using the natural
|
|
* ordering of the keys. This algorithm runs in n*log(n) time. All entries
|
|
* in the map must have keys which implement Comparable and are mutually
|
|
* comparable, otherwise map operations may throw a
|
|
* {@link ClassCastException}.
|
|
*
|
|
* @param map a Map, whose entries will be put into this TreeMap
|
|
* @throws ClassCastException if the keys in the provided Map are not
|
|
* comparable
|
|
* @throws NullPointerException if map is null
|
|
* @see Comparable
|
|
*/
|
|
public TreeMap(Map<? extends K, ? extends V> map)
|
|
{
|
|
this((Comparator) null);
|
|
putAll(map);
|
|
}
|
|
|
|
/**
|
|
* Instantiate a new TreeMap, initializing it with all of the elements in
|
|
* the provided SortedMap. The elements will be sorted using the same
|
|
* comparator as in the provided SortedMap. This runs in linear time.
|
|
*
|
|
* @param sm a SortedMap, whose entries will be put into this TreeMap
|
|
* @throws NullPointerException if sm is null
|
|
*/
|
|
public TreeMap(SortedMap<K, ? extends V> sm)
|
|
{
|
|
this(sm.comparator());
|
|
int pos = sm.size();
|
|
Iterator itr = sm.entrySet().iterator();
|
|
|
|
fabricateTree(pos);
|
|
Node node = firstNode();
|
|
|
|
while (--pos >= 0)
|
|
{
|
|
Map.Entry me = (Map.Entry) itr.next();
|
|
node.key = me.getKey();
|
|
node.value = me.getValue();
|
|
node = successor(node);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Clears the Map so it has no keys. This is O(1).
|
|
*/
|
|
public void clear()
|
|
{
|
|
if (size > 0)
|
|
{
|
|
modCount++;
|
|
root = nil;
|
|
size = 0;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns a shallow clone of this TreeMap. The Map itself is cloned,
|
|
* but its contents are not.
|
|
*
|
|
* @return the clone
|
|
*/
|
|
public Object clone()
|
|
{
|
|
TreeMap copy = null;
|
|
try
|
|
{
|
|
copy = (TreeMap) super.clone();
|
|
}
|
|
catch (CloneNotSupportedException x)
|
|
{
|
|
}
|
|
copy.entries = null;
|
|
copy.fabricateTree(size);
|
|
|
|
Node node = firstNode();
|
|
Node cnode = copy.firstNode();
|
|
|
|
while (node != nil)
|
|
{
|
|
cnode.key = node.key;
|
|
cnode.value = node.value;
|
|
node = successor(node);
|
|
cnode = copy.successor(cnode);
|
|
}
|
|
return copy;
|
|
}
|
|
|
|
/**
|
|
* Return the comparator used to sort this map, or null if it is by
|
|
* natural order.
|
|
*
|
|
* @return the map's comparator
|
|
*/
|
|
public Comparator<? super K> comparator()
|
|
{
|
|
return comparator;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the map contains a mapping for the given key.
|
|
*
|
|
* @param key the key to look for
|
|
* @return true if the key has a mapping
|
|
* @throws ClassCastException if key is not comparable to map elements
|
|
* @throws NullPointerException if key is null and the comparator is not
|
|
* tolerant of nulls
|
|
*/
|
|
public boolean containsKey(Object key)
|
|
{
|
|
return getNode((K) key) != nil;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the map contains at least one mapping to the given value.
|
|
* This requires linear time.
|
|
*
|
|
* @param value the value to look for
|
|
* @return true if the value appears in a mapping
|
|
*/
|
|
public boolean containsValue(Object value)
|
|
{
|
|
Node node = firstNode();
|
|
while (node != nil)
|
|
{
|
|
if (equals(value, node.value))
|
|
return true;
|
|
node = successor(node);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Returns a "set view" of this TreeMap's entries. The set is backed by
|
|
* the TreeMap, so changes in one show up in the other. The set supports
|
|
* element removal, but not element addition.<p>
|
|
*
|
|
* Note that the iterators for all three views, from keySet(), entrySet(),
|
|
* and values(), traverse the TreeMap in sorted sequence.
|
|
*
|
|
* @return a set view of the entries
|
|
* @see #keySet()
|
|
* @see #values()
|
|
* @see Map.Entry
|
|
*/
|
|
public Set<Map.Entry<K,V>> entrySet()
|
|
{
|
|
if (entries == null)
|
|
// Create an AbstractSet with custom implementations of those methods
|
|
// that can be overriden easily and efficiently.
|
|
entries = new NavigableEntrySet();
|
|
return entries;
|
|
}
|
|
|
|
/**
|
|
* Returns the first (lowest) key in the map.
|
|
*
|
|
* @return the first key
|
|
* @throws NoSuchElementException if the map is empty
|
|
*/
|
|
public K firstKey()
|
|
{
|
|
if (root == nil)
|
|
throw new NoSuchElementException();
|
|
return firstNode().key;
|
|
}
|
|
|
|
/**
|
|
* Return the value in this TreeMap associated with the supplied key,
|
|
* or <code>null</code> if the key maps to nothing. NOTE: Since the value
|
|
* could also be null, you must use containsKey to see if this key
|
|
* actually maps to something.
|
|
*
|
|
* @param key the key for which to fetch an associated value
|
|
* @return what the key maps to, if present
|
|
* @throws ClassCastException if key is not comparable to elements in the map
|
|
* @throws NullPointerException if key is null but the comparator does not
|
|
* tolerate nulls
|
|
* @see #put(Object, Object)
|
|
* @see #containsKey(Object)
|
|
*/
|
|
public V get(Object key)
|
|
{
|
|
// Exploit fact that nil.value == null.
|
|
return getNode((K) key).value;
|
|
}
|
|
|
|
/**
|
|
* Returns a view of this Map including all entries with keys less than
|
|
* <code>toKey</code>. The returned map is backed by the original, so changes
|
|
* in one appear in the other. The submap will throw an
|
|
* {@link IllegalArgumentException} for any attempt to access or add an
|
|
* element beyond the specified cutoff. The returned map does not include
|
|
* the endpoint; if you want inclusion, pass the successor element
|
|
* or call <code>headMap(toKey, true)</code>. This is equivalent to
|
|
* calling <code>headMap(toKey, false)</code>.
|
|
*
|
|
* @param toKey the (exclusive) cutoff point
|
|
* @return a view of the map less than the cutoff
|
|
* @throws ClassCastException if <code>toKey</code> is not compatible with
|
|
* the comparator (or is not Comparable, for natural ordering)
|
|
* @throws NullPointerException if toKey is null, but the comparator does not
|
|
* tolerate null elements
|
|
*/
|
|
public SortedMap<K, V> headMap(K toKey)
|
|
{
|
|
return headMap(toKey, false);
|
|
}
|
|
|
|
/**
|
|
* Returns a view of this Map including all entries with keys less than
|
|
* (or equal to, if <code>inclusive</code> is true) <code>toKey</code>.
|
|
* The returned map is backed by the original, so changes in one appear
|
|
* in the other. The submap will throw an {@link IllegalArgumentException}
|
|
* for any attempt to access or add an element beyond the specified cutoff.
|
|
*
|
|
* @param toKey the cutoff point
|
|
* @param inclusive true if the cutoff point should be included.
|
|
* @return a view of the map less than (or equal to, if <code>inclusive</code>
|
|
* is true) the cutoff.
|
|
* @throws ClassCastException if <code>toKey</code> is not compatible with
|
|
* the comparator (or is not Comparable, for natural ordering)
|
|
* @throws NullPointerException if toKey is null, but the comparator does not
|
|
* tolerate null elements
|
|
*/
|
|
public NavigableMap<K, V> headMap(K toKey, boolean inclusive)
|
|
{
|
|
return new SubMap((K)(Object)nil, inclusive
|
|
? successor(getNode(toKey)).key : toKey);
|
|
}
|
|
|
|
/**
|
|
* Returns a "set view" of this TreeMap's keys. The set is backed by the
|
|
* TreeMap, so changes in one show up in the other. The set supports
|
|
* element removal, but not element addition.
|
|
*
|
|
* @return a set view of the keys
|
|
* @see #values()
|
|
* @see #entrySet()
|
|
*/
|
|
public Set<K> keySet()
|
|
{
|
|
if (keys == null)
|
|
// Create an AbstractSet with custom implementations of those methods
|
|
// that can be overriden easily and efficiently.
|
|
keys = new KeySet();
|
|
return keys;
|
|
}
|
|
|
|
/**
|
|
* Returns the last (highest) key in the map.
|
|
*
|
|
* @return the last key
|
|
* @throws NoSuchElementException if the map is empty
|
|
*/
|
|
public K lastKey()
|
|
{
|
|
if (root == nil)
|
|
throw new NoSuchElementException("empty");
|
|
return lastNode().key;
|
|
}
|
|
|
|
/**
|
|
* Puts the supplied value into the Map, mapped by the supplied key.
|
|
* The value may be retrieved by any object which <code>equals()</code>
|
|
* this key. NOTE: Since the prior value could also be null, you must
|
|
* first use containsKey if you want to see if you are replacing the
|
|
* key's mapping.
|
|
*
|
|
* @param key the key used to locate the value
|
|
* @param value the value to be stored in the Map
|
|
* @return the prior mapping of the key, or null if there was none
|
|
* @throws ClassCastException if key is not comparable to current map keys
|
|
* @throws NullPointerException if key is null, but the comparator does
|
|
* not tolerate nulls
|
|
* @see #get(Object)
|
|
* @see Object#equals(Object)
|
|
*/
|
|
public V put(K key, V value)
|
|
{
|
|
Node<K,V> current = root;
|
|
Node<K,V> parent = nil;
|
|
int comparison = 0;
|
|
|
|
// Find new node's parent.
|
|
while (current != nil)
|
|
{
|
|
parent = current;
|
|
comparison = compare(key, current.key);
|
|
if (comparison > 0)
|
|
current = current.right;
|
|
else if (comparison < 0)
|
|
current = current.left;
|
|
else // Key already in tree.
|
|
return current.setValue(value);
|
|
}
|
|
|
|
// Set up new node.
|
|
Node n = new Node(key, value, RED);
|
|
n.parent = parent;
|
|
|
|
// Insert node in tree.
|
|
modCount++;
|
|
size++;
|
|
if (parent == nil)
|
|
{
|
|
// Special case inserting into an empty tree.
|
|
root = n;
|
|
return null;
|
|
}
|
|
if (comparison > 0)
|
|
parent.right = n;
|
|
else
|
|
parent.left = n;
|
|
|
|
// Rebalance after insert.
|
|
insertFixup(n);
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Copies all elements of the given map into this TreeMap. If this map
|
|
* already has a mapping for a key, the new mapping replaces the current
|
|
* one.
|
|
*
|
|
* @param m the map to be added
|
|
* @throws ClassCastException if a key in m is not comparable with keys
|
|
* in the map
|
|
* @throws NullPointerException if a key in m is null, and the comparator
|
|
* does not tolerate nulls
|
|
*/
|
|
public void putAll(Map<? extends K, ? extends V> m)
|
|
{
|
|
Iterator itr = m.entrySet().iterator();
|
|
int pos = m.size();
|
|
while (--pos >= 0)
|
|
{
|
|
Map.Entry<K,V> e = (Map.Entry<K,V>) itr.next();
|
|
put(e.getKey(), e.getValue());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Removes from the TreeMap and returns the value which is mapped by the
|
|
* supplied key. If the key maps to nothing, then the TreeMap remains
|
|
* unchanged, and <code>null</code> is returned. NOTE: Since the value
|
|
* could also be null, you must use containsKey to see if you are
|
|
* actually removing a mapping.
|
|
*
|
|
* @param key the key used to locate the value to remove
|
|
* @return whatever the key mapped to, if present
|
|
* @throws ClassCastException if key is not comparable to current map keys
|
|
* @throws NullPointerException if key is null, but the comparator does
|
|
* not tolerate nulls
|
|
*/
|
|
public V remove(Object key)
|
|
{
|
|
Node<K, V> n = getNode((K)key);
|
|
if (n == nil)
|
|
return null;
|
|
// Note: removeNode can alter the contents of n, so save value now.
|
|
V result = n.value;
|
|
removeNode(n);
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Returns the number of key-value mappings currently in this Map.
|
|
*
|
|
* @return the size
|
|
*/
|
|
public int size()
|
|
{
|
|
return size;
|
|
}
|
|
|
|
/**
|
|
* Returns a view of this Map including all entries with keys greater or
|
|
* equal to <code>fromKey</code> and less than <code>toKey</code> (a
|
|
* half-open interval). The returned map is backed by the original, so
|
|
* changes in one appear in the other. The submap will throw an
|
|
* {@link IllegalArgumentException} for any attempt to access or add an
|
|
* element beyond the specified cutoffs. The returned map includes the low
|
|
* endpoint but not the high; if you want to reverse this behavior on
|
|
* either end, pass in the successor element or call
|
|
* {@link #subMap(K,boolean,K,boolean)}. This call is equivalent to
|
|
* <code>subMap(fromKey, true, toKey, false)</code>.
|
|
*
|
|
* @param fromKey the (inclusive) low cutoff point
|
|
* @param toKey the (exclusive) high cutoff point
|
|
* @return a view of the map between the cutoffs
|
|
* @throws ClassCastException if either cutoff is not compatible with
|
|
* the comparator (or is not Comparable, for natural ordering)
|
|
* @throws NullPointerException if fromKey or toKey is null, but the
|
|
* comparator does not tolerate null elements
|
|
* @throws IllegalArgumentException if fromKey is greater than toKey
|
|
*/
|
|
public SortedMap<K, V> subMap(K fromKey, K toKey)
|
|
{
|
|
return subMap(fromKey, true, toKey, false);
|
|
}
|
|
|
|
/**
|
|
* Returns a view of this Map including all entries with keys greater (or
|
|
* equal to, if <code>fromInclusive</code> is true) <code>fromKey</code> and
|
|
* less than (or equal to, if <code>toInclusive</code> is true)
|
|
* <code>toKey</code>. The returned map is backed by the original, so
|
|
* changes in one appear in the other. The submap will throw an
|
|
* {@link IllegalArgumentException} for any attempt to access or add an
|
|
* element beyond the specified cutoffs.
|
|
*
|
|
* @param fromKey the low cutoff point
|
|
* @param fromInclusive true if the low cutoff point should be included.
|
|
* @param toKey the high cutoff point
|
|
* @param toInclusive true if the high cutoff point should be included.
|
|
* @return a view of the map for the specified range.
|
|
* @throws ClassCastException if either cutoff is not compatible with
|
|
* the comparator (or is not Comparable, for natural ordering)
|
|
* @throws NullPointerException if fromKey or toKey is null, but the
|
|
* comparator does not tolerate null elements
|
|
* @throws IllegalArgumentException if fromKey is greater than toKey
|
|
*/
|
|
public NavigableMap<K, V> subMap(K fromKey, boolean fromInclusive,
|
|
K toKey, boolean toInclusive)
|
|
{
|
|
return new SubMap(fromInclusive ? fromKey : successor(getNode(fromKey)).key,
|
|
toInclusive ? successor(getNode(toKey)).key : toKey);
|
|
}
|
|
|
|
/**
|
|
* Returns a view of this Map including all entries with keys greater or
|
|
* equal to <code>fromKey</code>. The returned map is backed by the
|
|
* original, so changes in one appear in the other. The submap will throw an
|
|
* {@link IllegalArgumentException} for any attempt to access or add an
|
|
* element beyond the specified cutoff. The returned map includes the
|
|
* endpoint; if you want to exclude it, pass in the successor element.
|
|
* This is equivalent to calling <code>tailMap(fromKey, true)</code>.
|
|
*
|
|
* @param fromKey the (inclusive) low cutoff point
|
|
* @return a view of the map above the cutoff
|
|
* @throws ClassCastException if <code>fromKey</code> is not compatible with
|
|
* the comparator (or is not Comparable, for natural ordering)
|
|
* @throws NullPointerException if fromKey is null, but the comparator
|
|
* does not tolerate null elements
|
|
*/
|
|
public SortedMap<K, V> tailMap(K fromKey)
|
|
{
|
|
return tailMap(fromKey, true);
|
|
}
|
|
|
|
/**
|
|
* Returns a view of this Map including all entries with keys greater or
|
|
* equal to <code>fromKey</code>. The returned map is backed by the
|
|
* original, so changes in one appear in the other. The submap will throw an
|
|
* {@link IllegalArgumentException} for any attempt to access or add an
|
|
* element beyond the specified cutoff. The returned map includes the
|
|
* endpoint; if you want to exclude it, pass in the successor element.
|
|
*
|
|
* @param fromKey the low cutoff point
|
|
* @param inclusive true if the cutoff point should be included.
|
|
* @return a view of the map above the cutoff
|
|
* @throws ClassCastException if <code>fromKey</code> is not compatible with
|
|
* the comparator (or is not Comparable, for natural ordering)
|
|
* @throws NullPointerException if fromKey is null, but the comparator
|
|
* does not tolerate null elements
|
|
*/
|
|
public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive)
|
|
{
|
|
return new SubMap(inclusive ? fromKey : successor(getNode(fromKey)).key,
|
|
(K)(Object)nil);
|
|
}
|
|
|
|
/**
|
|
* Returns a "collection view" (or "bag view") of this TreeMap's values.
|
|
* The collection is backed by the TreeMap, so changes in one show up
|
|
* in the other. The collection supports element removal, but not element
|
|
* addition.
|
|
*
|
|
* @return a bag view of the values
|
|
* @see #keySet()
|
|
* @see #entrySet()
|
|
*/
|
|
public Collection<V> values()
|
|
{
|
|
if (values == null)
|
|
// We don't bother overriding many of the optional methods, as doing so
|
|
// wouldn't provide any significant performance advantage.
|
|
values = new AbstractCollection<V>()
|
|
{
|
|
public int size()
|
|
{
|
|
return size;
|
|
}
|
|
|
|
public Iterator<V> iterator()
|
|
{
|
|
return new TreeIterator(VALUES);
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
TreeMap.this.clear();
|
|
}
|
|
};
|
|
return values;
|
|
}
|
|
|
|
/**
|
|
* Compares two elements by the set comparator, or by natural ordering.
|
|
* Package visible for use by nested classes.
|
|
*
|
|
* @param o1 the first object
|
|
* @param o2 the second object
|
|
* @throws ClassCastException if o1 and o2 are not mutually comparable,
|
|
* or are not Comparable with natural ordering
|
|
* @throws NullPointerException if o1 or o2 is null with natural ordering
|
|
*/
|
|
final int compare(K o1, K o2)
|
|
{
|
|
return (comparator == null
|
|
? ((Comparable) o1).compareTo(o2)
|
|
: comparator.compare(o1, o2));
|
|
}
|
|
|
|
/**
|
|
* Maintain red-black balance after deleting a node.
|
|
*
|
|
* @param node the child of the node just deleted, possibly nil
|
|
* @param parent the parent of the node just deleted, never nil
|
|
*/
|
|
private void deleteFixup(Node<K,V> node, Node<K,V> parent)
|
|
{
|
|
// if (parent == nil)
|
|
// throw new InternalError();
|
|
// If a black node has been removed, we need to rebalance to avoid
|
|
// violating the "same number of black nodes on any path" rule. If
|
|
// node is red, we can simply recolor it black and all is well.
|
|
while (node != root && node.color == BLACK)
|
|
{
|
|
if (node == parent.left)
|
|
{
|
|
// Rebalance left side.
|
|
Node<K,V> sibling = parent.right;
|
|
// if (sibling == nil)
|
|
// throw new InternalError();
|
|
if (sibling.color == RED)
|
|
{
|
|
// Case 1: Sibling is red.
|
|
// Recolor sibling and parent, and rotate parent left.
|
|
sibling.color = BLACK;
|
|
parent.color = RED;
|
|
rotateLeft(parent);
|
|
sibling = parent.right;
|
|
}
|
|
|
|
if (sibling.left.color == BLACK && sibling.right.color == BLACK)
|
|
{
|
|
// Case 2: Sibling has no red children.
|
|
// Recolor sibling, and move to parent.
|
|
sibling.color = RED;
|
|
node = parent;
|
|
parent = parent.parent;
|
|
}
|
|
else
|
|
{
|
|
if (sibling.right.color == BLACK)
|
|
{
|
|
// Case 3: Sibling has red left child.
|
|
// Recolor sibling and left child, rotate sibling right.
|
|
sibling.left.color = BLACK;
|
|
sibling.color = RED;
|
|
rotateRight(sibling);
|
|
sibling = parent.right;
|
|
}
|
|
// Case 4: Sibling has red right child. Recolor sibling,
|
|
// right child, and parent, and rotate parent left.
|
|
sibling.color = parent.color;
|
|
parent.color = BLACK;
|
|
sibling.right.color = BLACK;
|
|
rotateLeft(parent);
|
|
node = root; // Finished.
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Symmetric "mirror" of left-side case.
|
|
Node<K,V> sibling = parent.left;
|
|
// if (sibling == nil)
|
|
// throw new InternalError();
|
|
if (sibling.color == RED)
|
|
{
|
|
// Case 1: Sibling is red.
|
|
// Recolor sibling and parent, and rotate parent right.
|
|
sibling.color = BLACK;
|
|
parent.color = RED;
|
|
rotateRight(parent);
|
|
sibling = parent.left;
|
|
}
|
|
|
|
if (sibling.right.color == BLACK && sibling.left.color == BLACK)
|
|
{
|
|
// Case 2: Sibling has no red children.
|
|
// Recolor sibling, and move to parent.
|
|
sibling.color = RED;
|
|
node = parent;
|
|
parent = parent.parent;
|
|
}
|
|
else
|
|
{
|
|
if (sibling.left.color == BLACK)
|
|
{
|
|
// Case 3: Sibling has red right child.
|
|
// Recolor sibling and right child, rotate sibling left.
|
|
sibling.right.color = BLACK;
|
|
sibling.color = RED;
|
|
rotateLeft(sibling);
|
|
sibling = parent.left;
|
|
}
|
|
// Case 4: Sibling has red left child. Recolor sibling,
|
|
// left child, and parent, and rotate parent right.
|
|
sibling.color = parent.color;
|
|
parent.color = BLACK;
|
|
sibling.left.color = BLACK;
|
|
rotateRight(parent);
|
|
node = root; // Finished.
|
|
}
|
|
}
|
|
}
|
|
node.color = BLACK;
|
|
}
|
|
|
|
/**
|
|
* Construct a perfectly balanced tree consisting of n "blank" nodes. This
|
|
* permits a tree to be generated from pre-sorted input in linear time.
|
|
*
|
|
* @param count the number of blank nodes, non-negative
|
|
*/
|
|
private void fabricateTree(final int count)
|
|
{
|
|
if (count == 0)
|
|
{
|
|
root = nil;
|
|
size = 0;
|
|
return;
|
|
}
|
|
|
|
// We color every row of nodes black, except for the overflow nodes.
|
|
// I believe that this is the optimal arrangement. We construct the tree
|
|
// in place by temporarily linking each node to the next node in the row,
|
|
// then updating those links to the children when working on the next row.
|
|
|
|
// Make the root node.
|
|
root = new Node(null, null, BLACK);
|
|
size = count;
|
|
Node row = root;
|
|
int rowsize;
|
|
|
|
// Fill each row that is completely full of nodes.
|
|
for (rowsize = 2; rowsize + rowsize <= count; rowsize <<= 1)
|
|
{
|
|
Node parent = row;
|
|
Node last = null;
|
|
for (int i = 0; i < rowsize; i += 2)
|
|
{
|
|
Node left = new Node(null, null, BLACK);
|
|
Node right = new Node(null, null, BLACK);
|
|
left.parent = parent;
|
|
left.right = right;
|
|
right.parent = parent;
|
|
parent.left = left;
|
|
Node next = parent.right;
|
|
parent.right = right;
|
|
parent = next;
|
|
if (last != null)
|
|
last.right = left;
|
|
last = right;
|
|
}
|
|
row = row.left;
|
|
}
|
|
|
|
// Now do the partial final row in red.
|
|
int overflow = count - rowsize;
|
|
Node parent = row;
|
|
int i;
|
|
for (i = 0; i < overflow; i += 2)
|
|
{
|
|
Node left = new Node(null, null, RED);
|
|
Node right = new Node(null, null, RED);
|
|
left.parent = parent;
|
|
right.parent = parent;
|
|
parent.left = left;
|
|
Node next = parent.right;
|
|
parent.right = right;
|
|
parent = next;
|
|
}
|
|
// Add a lone left node if necessary.
|
|
if (i - overflow == 0)
|
|
{
|
|
Node left = new Node(null, null, RED);
|
|
left.parent = parent;
|
|
parent.left = left;
|
|
parent = parent.right;
|
|
left.parent.right = nil;
|
|
}
|
|
// Unlink the remaining nodes of the previous row.
|
|
while (parent != nil)
|
|
{
|
|
Node next = parent.right;
|
|
parent.right = nil;
|
|
parent = next;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the first sorted node in the map, or nil if empty. Package
|
|
* visible for use by nested classes.
|
|
*
|
|
* @return the first node
|
|
*/
|
|
final Node<K, V> firstNode()
|
|
{
|
|
// Exploit fact that nil.left == nil.
|
|
Node node = root;
|
|
while (node.left != nil)
|
|
node = node.left;
|
|
return node;
|
|
}
|
|
|
|
/**
|
|
* Return the TreeMap.Node associated with key, or the nil node if no such
|
|
* node exists in the tree. Package visible for use by nested classes.
|
|
*
|
|
* @param key the key to search for
|
|
* @return the node where the key is found, or nil
|
|
*/
|
|
final Node<K, V> getNode(K key)
|
|
{
|
|
Node<K,V> current = root;
|
|
while (current != nil)
|
|
{
|
|
int comparison = compare(key, current.key);
|
|
if (comparison > 0)
|
|
current = current.right;
|
|
else if (comparison < 0)
|
|
current = current.left;
|
|
else
|
|
return current;
|
|
}
|
|
return current;
|
|
}
|
|
|
|
/**
|
|
* Find the "highest" node which is < key. If key is nil, return last
|
|
* node. Package visible for use by nested classes.
|
|
*
|
|
* @param key the upper bound, exclusive
|
|
* @return the previous node
|
|
*/
|
|
final Node<K,V> highestLessThan(K key)
|
|
{
|
|
return highestLessThan(key, false);
|
|
}
|
|
|
|
/**
|
|
* Find the "highest" node which is < (or equal to,
|
|
* if <code>equal</code> is true) key. If key is nil,
|
|
* return last node. Package visible for use by nested
|
|
* classes.
|
|
*
|
|
* @param key the upper bound, exclusive
|
|
* @param equal true if the key should be returned if found.
|
|
* @return the previous node
|
|
*/
|
|
final Node<K,V> highestLessThan(K key, boolean equal)
|
|
{
|
|
if (key == nil)
|
|
return lastNode();
|
|
|
|
Node<K,V> last = nil;
|
|
Node<K,V> current = root;
|
|
int comparison = 0;
|
|
|
|
while (current != nil)
|
|
{
|
|
last = current;
|
|
comparison = compare(key, current.key);
|
|
if (comparison > 0)
|
|
current = current.right;
|
|
else if (comparison < 0)
|
|
current = current.left;
|
|
else // Exact match.
|
|
return (equal ? last : predecessor(last));
|
|
}
|
|
return comparison < 0 ? predecessor(last) : last;
|
|
}
|
|
|
|
/**
|
|
* Maintain red-black balance after inserting a new node.
|
|
*
|
|
* @param n the newly inserted node
|
|
*/
|
|
private void insertFixup(Node<K,V> n)
|
|
{
|
|
// Only need to rebalance when parent is a RED node, and while at least
|
|
// 2 levels deep into the tree (ie: node has a grandparent). Remember
|
|
// that nil.color == BLACK.
|
|
while (n.parent.color == RED && n.parent.parent != nil)
|
|
{
|
|
if (n.parent == n.parent.parent.left)
|
|
{
|
|
Node uncle = n.parent.parent.right;
|
|
// Uncle may be nil, in which case it is BLACK.
|
|
if (uncle.color == RED)
|
|
{
|
|
// Case 1. Uncle is RED: Change colors of parent, uncle,
|
|
// and grandparent, and move n to grandparent.
|
|
n.parent.color = BLACK;
|
|
uncle.color = BLACK;
|
|
uncle.parent.color = RED;
|
|
n = uncle.parent;
|
|
}
|
|
else
|
|
{
|
|
if (n == n.parent.right)
|
|
{
|
|
// Case 2. Uncle is BLACK and x is right child.
|
|
// Move n to parent, and rotate n left.
|
|
n = n.parent;
|
|
rotateLeft(n);
|
|
}
|
|
// Case 3. Uncle is BLACK and x is left child.
|
|
// Recolor parent, grandparent, and rotate grandparent right.
|
|
n.parent.color = BLACK;
|
|
n.parent.parent.color = RED;
|
|
rotateRight(n.parent.parent);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Mirror image of above code.
|
|
Node uncle = n.parent.parent.left;
|
|
// Uncle may be nil, in which case it is BLACK.
|
|
if (uncle.color == RED)
|
|
{
|
|
// Case 1. Uncle is RED: Change colors of parent, uncle,
|
|
// and grandparent, and move n to grandparent.
|
|
n.parent.color = BLACK;
|
|
uncle.color = BLACK;
|
|
uncle.parent.color = RED;
|
|
n = uncle.parent;
|
|
}
|
|
else
|
|
{
|
|
if (n == n.parent.left)
|
|
{
|
|
// Case 2. Uncle is BLACK and x is left child.
|
|
// Move n to parent, and rotate n right.
|
|
n = n.parent;
|
|
rotateRight(n);
|
|
}
|
|
// Case 3. Uncle is BLACK and x is right child.
|
|
// Recolor parent, grandparent, and rotate grandparent left.
|
|
n.parent.color = BLACK;
|
|
n.parent.parent.color = RED;
|
|
rotateLeft(n.parent.parent);
|
|
}
|
|
}
|
|
}
|
|
root.color = BLACK;
|
|
}
|
|
|
|
/**
|
|
* Returns the last sorted node in the map, or nil if empty.
|
|
*
|
|
* @return the last node
|
|
*/
|
|
private Node<K,V> lastNode()
|
|
{
|
|
// Exploit fact that nil.right == nil.
|
|
Node node = root;
|
|
while (node.right != nil)
|
|
node = node.right;
|
|
return node;
|
|
}
|
|
|
|
/**
|
|
* Find the "lowest" node which is >= key. If key is nil, return either
|
|
* nil or the first node, depending on the parameter first. Package visible
|
|
* for use by nested classes.
|
|
*
|
|
* @param key the lower bound, inclusive
|
|
* @param first true to return the first element instead of nil for nil key
|
|
* @return the next node
|
|
*/
|
|
final Node<K,V> lowestGreaterThan(K key, boolean first)
|
|
{
|
|
return lowestGreaterThan(key, first, true);
|
|
}
|
|
|
|
/**
|
|
* Find the "lowest" node which is > (or equal to, if <code>equal</code>
|
|
* is true) key. If key is nil, return either nil or the first node, depending
|
|
* on the parameter first. Package visible for use by nested classes.
|
|
*
|
|
* @param key the lower bound, inclusive
|
|
* @param first true to return the first element instead of nil for nil key
|
|
* @param equal true if the key should be returned if found.
|
|
* @return the next node
|
|
*/
|
|
final Node<K,V> lowestGreaterThan(K key, boolean first, boolean equal)
|
|
{
|
|
if (key == nil)
|
|
return first ? firstNode() : nil;
|
|
|
|
Node<K,V> last = nil;
|
|
Node<K,V> current = root;
|
|
int comparison = 0;
|
|
|
|
while (current != nil)
|
|
{
|
|
last = current;
|
|
comparison = compare(key, current.key);
|
|
if (comparison > 0)
|
|
current = current.right;
|
|
else if (comparison < 0)
|
|
current = current.left;
|
|
else
|
|
return (equal ? current : successor(current));
|
|
}
|
|
return comparison > 0 ? successor(last) : last;
|
|
}
|
|
|
|
/**
|
|
* Return the node preceding the given one, or nil if there isn't one.
|
|
*
|
|
* @param node the current node, not nil
|
|
* @return the prior node in sorted order
|
|
*/
|
|
private Node<K,V> predecessor(Node<K,V> node)
|
|
{
|
|
if (node.left != nil)
|
|
{
|
|
node = node.left;
|
|
while (node.right != nil)
|
|
node = node.right;
|
|
return node;
|
|
}
|
|
|
|
Node parent = node.parent;
|
|
// Exploit fact that nil.left == nil and node is non-nil.
|
|
while (node == parent.left)
|
|
{
|
|
node = parent;
|
|
parent = node.parent;
|
|
}
|
|
return parent;
|
|
}
|
|
|
|
/**
|
|
* Construct a tree from sorted keys in linear time. Package visible for
|
|
* use by TreeSet.
|
|
*
|
|
* @param s the stream to read from
|
|
* @param count the number of keys to read
|
|
* @param readValues true to read values, false to insert "" as the value
|
|
* @throws ClassNotFoundException if the underlying stream fails
|
|
* @throws IOException if the underlying stream fails
|
|
* @see #readObject(ObjectInputStream)
|
|
* @see TreeSet#readObject(ObjectInputStream)
|
|
*/
|
|
final void putFromObjStream(ObjectInputStream s, int count,
|
|
boolean readValues)
|
|
throws IOException, ClassNotFoundException
|
|
{
|
|
fabricateTree(count);
|
|
Node node = firstNode();
|
|
|
|
while (--count >= 0)
|
|
{
|
|
node.key = s.readObject();
|
|
node.value = readValues ? s.readObject() : "";
|
|
node = successor(node);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Construct a tree from sorted keys in linear time, with values of "".
|
|
* Package visible for use by TreeSet, which uses a value type of String.
|
|
*
|
|
* @param keys the iterator over the sorted keys
|
|
* @param count the number of nodes to insert
|
|
* @see TreeSet#TreeSet(SortedSet)
|
|
*/
|
|
final void putKeysLinear(Iterator<K> keys, int count)
|
|
{
|
|
fabricateTree(count);
|
|
Node<K,V> node = firstNode();
|
|
|
|
while (--count >= 0)
|
|
{
|
|
node.key = keys.next();
|
|
node.value = (V) "";
|
|
node = successor(node);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Deserializes this object from the given stream.
|
|
*
|
|
* @param s the stream to read from
|
|
* @throws ClassNotFoundException if the underlying stream fails
|
|
* @throws IOException if the underlying stream fails
|
|
* @serialData the <i>size</i> (int), followed by key (Object) and value
|
|
* (Object) pairs in sorted order
|
|
*/
|
|
private void readObject(ObjectInputStream s)
|
|
throws IOException, ClassNotFoundException
|
|
{
|
|
s.defaultReadObject();
|
|
int size = s.readInt();
|
|
putFromObjStream(s, size, true);
|
|
}
|
|
|
|
/**
|
|
* Remove node from tree. This will increment modCount and decrement size.
|
|
* Node must exist in the tree. Package visible for use by nested classes.
|
|
*
|
|
* @param node the node to remove
|
|
*/
|
|
final void removeNode(Node<K,V> node)
|
|
{
|
|
Node<K,V> splice;
|
|
Node<K,V> child;
|
|
|
|
modCount++;
|
|
size--;
|
|
|
|
// Find splice, the node at the position to actually remove from the tree.
|
|
if (node.left == nil)
|
|
{
|
|
// Node to be deleted has 0 or 1 children.
|
|
splice = node;
|
|
child = node.right;
|
|
}
|
|
else if (node.right == nil)
|
|
{
|
|
// Node to be deleted has 1 child.
|
|
splice = node;
|
|
child = node.left;
|
|
}
|
|
else
|
|
{
|
|
// Node has 2 children. Splice is node's predecessor, and we swap
|
|
// its contents into node.
|
|
splice = node.left;
|
|
while (splice.right != nil)
|
|
splice = splice.right;
|
|
child = splice.left;
|
|
node.key = splice.key;
|
|
node.value = splice.value;
|
|
}
|
|
|
|
// Unlink splice from the tree.
|
|
Node parent = splice.parent;
|
|
if (child != nil)
|
|
child.parent = parent;
|
|
if (parent == nil)
|
|
{
|
|
// Special case for 0 or 1 node remaining.
|
|
root = child;
|
|
return;
|
|
}
|
|
if (splice == parent.left)
|
|
parent.left = child;
|
|
else
|
|
parent.right = child;
|
|
|
|
if (splice.color == BLACK)
|
|
deleteFixup(child, parent);
|
|
}
|
|
|
|
/**
|
|
* Rotate node n to the left.
|
|
*
|
|
* @param node the node to rotate
|
|
*/
|
|
private void rotateLeft(Node<K,V> node)
|
|
{
|
|
Node child = node.right;
|
|
// if (node == nil || child == nil)
|
|
// throw new InternalError();
|
|
|
|
// Establish node.right link.
|
|
node.right = child.left;
|
|
if (child.left != nil)
|
|
child.left.parent = node;
|
|
|
|
// Establish child->parent link.
|
|
child.parent = node.parent;
|
|
if (node.parent != nil)
|
|
{
|
|
if (node == node.parent.left)
|
|
node.parent.left = child;
|
|
else
|
|
node.parent.right = child;
|
|
}
|
|
else
|
|
root = child;
|
|
|
|
// Link n and child.
|
|
child.left = node;
|
|
node.parent = child;
|
|
}
|
|
|
|
/**
|
|
* Rotate node n to the right.
|
|
*
|
|
* @param node the node to rotate
|
|
*/
|
|
private void rotateRight(Node<K,V> node)
|
|
{
|
|
Node child = node.left;
|
|
// if (node == nil || child == nil)
|
|
// throw new InternalError();
|
|
|
|
// Establish node.left link.
|
|
node.left = child.right;
|
|
if (child.right != nil)
|
|
child.right.parent = node;
|
|
|
|
// Establish child->parent link.
|
|
child.parent = node.parent;
|
|
if (node.parent != nil)
|
|
{
|
|
if (node == node.parent.right)
|
|
node.parent.right = child;
|
|
else
|
|
node.parent.left = child;
|
|
}
|
|
else
|
|
root = child;
|
|
|
|
// Link n and child.
|
|
child.right = node;
|
|
node.parent = child;
|
|
}
|
|
|
|
/**
|
|
* Return the node following the given one, or nil if there isn't one.
|
|
* Package visible for use by nested classes.
|
|
*
|
|
* @param node the current node, not nil
|
|
* @return the next node in sorted order
|
|
*/
|
|
final Node<K,V> successor(Node<K,V> node)
|
|
{
|
|
if (node.right != nil)
|
|
{
|
|
node = node.right;
|
|
while (node.left != nil)
|
|
node = node.left;
|
|
return node;
|
|
}
|
|
|
|
Node<K,V> parent = node.parent;
|
|
// Exploit fact that nil.right == nil and node is non-nil.
|
|
while (node == parent.right)
|
|
{
|
|
node = parent;
|
|
parent = parent.parent;
|
|
}
|
|
return parent;
|
|
}
|
|
|
|
/**
|
|
* Serializes this object to the given stream.
|
|
*
|
|
* @param s the stream to write to
|
|
* @throws IOException if the underlying stream fails
|
|
* @serialData the <i>size</i> (int), followed by key (Object) and value
|
|
* (Object) pairs in sorted order
|
|
*/
|
|
private void writeObject(ObjectOutputStream s) throws IOException
|
|
{
|
|
s.defaultWriteObject();
|
|
|
|
Node node = firstNode();
|
|
s.writeInt(size);
|
|
while (node != nil)
|
|
{
|
|
s.writeObject(node.key);
|
|
s.writeObject(node.value);
|
|
node = successor(node);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Iterate over TreeMap's entries. This implementation is parameterized
|
|
* to give a sequential view of keys, values, or entries.
|
|
*
|
|
* @author Eric Blake (ebb9@email.byu.edu)
|
|
*/
|
|
private final class TreeIterator implements Iterator
|
|
{
|
|
/**
|
|
* The type of this Iterator: {@link #KEYS}, {@link #VALUES},
|
|
* or {@link #ENTRIES}.
|
|
*/
|
|
private final int type;
|
|
/** The number of modifications to the backing Map that we know about. */
|
|
private int knownMod = modCount;
|
|
/** The last Entry returned by a next() call. */
|
|
private Node last;
|
|
/** The next entry that should be returned by next(). */
|
|
private Node next;
|
|
/**
|
|
* The last node visible to this iterator. This is used when iterating
|
|
* on a SubMap.
|
|
*/
|
|
private final Node max;
|
|
|
|
/**
|
|
* Construct a new TreeIterator with the supplied type.
|
|
* @param type {@link #KEYS}, {@link #VALUES}, or {@link #ENTRIES}
|
|
*/
|
|
TreeIterator(int type)
|
|
{
|
|
this(type, firstNode(), nil);
|
|
}
|
|
|
|
/**
|
|
* Construct a new TreeIterator with the supplied type. Iteration will
|
|
* be from "first" (inclusive) to "max" (exclusive).
|
|
*
|
|
* @param type {@link #KEYS}, {@link #VALUES}, or {@link #ENTRIES}
|
|
* @param first where to start iteration, nil for empty iterator
|
|
* @param max the cutoff for iteration, nil for all remaining nodes
|
|
*/
|
|
TreeIterator(int type, Node first, Node max)
|
|
{
|
|
this.type = type;
|
|
this.next = first;
|
|
this.max = max;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the Iterator has more elements.
|
|
* @return true if there are more elements
|
|
*/
|
|
public boolean hasNext()
|
|
{
|
|
return next != max;
|
|
}
|
|
|
|
/**
|
|
* Returns the next element in the Iterator's sequential view.
|
|
* @return the next element
|
|
* @throws ConcurrentModificationException if the TreeMap was modified
|
|
* @throws NoSuchElementException if there is none
|
|
*/
|
|
public Object next()
|
|
{
|
|
if (knownMod != modCount)
|
|
throw new ConcurrentModificationException();
|
|
if (next == max)
|
|
throw new NoSuchElementException();
|
|
last = next;
|
|
next = successor(last);
|
|
|
|
if (type == VALUES)
|
|
return last.value;
|
|
else if (type == KEYS)
|
|
return last.key;
|
|
return last;
|
|
}
|
|
|
|
/**
|
|
* Removes from the backing TreeMap the last element which was fetched
|
|
* with the <code>next()</code> method.
|
|
* @throws ConcurrentModificationException if the TreeMap was modified
|
|
* @throws IllegalStateException if called when there is no last element
|
|
*/
|
|
public void remove()
|
|
{
|
|
if (last == null)
|
|
throw new IllegalStateException();
|
|
if (knownMod != modCount)
|
|
throw new ConcurrentModificationException();
|
|
|
|
removeNode(last);
|
|
last = null;
|
|
knownMod++;
|
|
}
|
|
} // class TreeIterator
|
|
|
|
/**
|
|
* Implementation of {@link #subMap(Object, Object)} and other map
|
|
* ranges. This class provides a view of a portion of the original backing
|
|
* map, and throws {@link IllegalArgumentException} for attempts to
|
|
* access beyond that range.
|
|
*
|
|
* @author Eric Blake (ebb9@email.byu.edu)
|
|
*/
|
|
private final class SubMap
|
|
extends AbstractMap<K,V>
|
|
implements NavigableMap<K,V>
|
|
{
|
|
/**
|
|
* The lower range of this view, inclusive, or nil for unbounded.
|
|
* Package visible for use by nested classes.
|
|
*/
|
|
final K minKey;
|
|
|
|
/**
|
|
* The upper range of this view, exclusive, or nil for unbounded.
|
|
* Package visible for use by nested classes.
|
|
*/
|
|
final K maxKey;
|
|
|
|
/**
|
|
* The cache for {@link #entrySet()}.
|
|
*/
|
|
private Set<Map.Entry<K,V>> entries;
|
|
|
|
/**
|
|
* The cache for {@link #descendingMap()}.
|
|
*/
|
|
private NavigableMap<K,V> descendingMap;
|
|
|
|
/**
|
|
* The cache for {@link #navigableKeySet()}.
|
|
*/
|
|
private NavigableSet<K> nKeys;
|
|
|
|
/**
|
|
* Create a SubMap representing the elements between minKey (inclusive)
|
|
* and maxKey (exclusive). If minKey is nil, SubMap has no lower bound
|
|
* (headMap). If maxKey is nil, the SubMap has no upper bound (tailMap).
|
|
*
|
|
* @param minKey the lower bound
|
|
* @param maxKey the upper bound
|
|
* @throws IllegalArgumentException if minKey > maxKey
|
|
*/
|
|
SubMap(K minKey, K maxKey)
|
|
{
|
|
if (minKey != nil && maxKey != nil && compare(minKey, maxKey) > 0)
|
|
throw new IllegalArgumentException("fromKey > toKey");
|
|
this.minKey = minKey;
|
|
this.maxKey = maxKey;
|
|
}
|
|
|
|
/**
|
|
* Check if "key" is in within the range bounds for this SubMap. The
|
|
* lower ("from") SubMap range is inclusive, and the upper ("to") bound
|
|
* is exclusive. Package visible for use by nested classes.
|
|
*
|
|
* @param key the key to check
|
|
* @return true if the key is in range
|
|
*/
|
|
boolean keyInRange(K key)
|
|
{
|
|
return ((minKey == nil || compare(key, minKey) >= 0)
|
|
&& (maxKey == nil || compare(key, maxKey) < 0));
|
|
}
|
|
|
|
public Entry<K,V> ceilingEntry(K key)
|
|
{
|
|
Entry<K,V> n = TreeMap.this.ceilingEntry(key);
|
|
if (n != null && keyInRange(n.getKey()))
|
|
return n;
|
|
return null;
|
|
}
|
|
|
|
public K ceilingKey(K key)
|
|
{
|
|
K found = TreeMap.this.ceilingKey(key);
|
|
if (keyInRange(found))
|
|
return found;
|
|
else
|
|
return null;
|
|
}
|
|
|
|
public NavigableSet<K> descendingKeySet()
|
|
{
|
|
return descendingMap().navigableKeySet();
|
|
}
|
|
|
|
public NavigableMap<K,V> descendingMap()
|
|
{
|
|
if (descendingMap == null)
|
|
descendingMap = new DescendingMap(this);
|
|
return descendingMap;
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
Node next = lowestGreaterThan(minKey, true);
|
|
Node max = lowestGreaterThan(maxKey, false);
|
|
while (next != max)
|
|
{
|
|
Node current = next;
|
|
next = successor(current);
|
|
removeNode(current);
|
|
}
|
|
}
|
|
|
|
public Comparator<? super K> comparator()
|
|
{
|
|
return comparator;
|
|
}
|
|
|
|
public boolean containsKey(Object key)
|
|
{
|
|
return keyInRange((K) key) && TreeMap.this.containsKey(key);
|
|
}
|
|
|
|
public boolean containsValue(Object value)
|
|
{
|
|
Node node = lowestGreaterThan(minKey, true);
|
|
Node max = lowestGreaterThan(maxKey, false);
|
|
while (node != max)
|
|
{
|
|
if (equals(value, node.getValue()))
|
|
return true;
|
|
node = successor(node);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public Set<Map.Entry<K,V>> entrySet()
|
|
{
|
|
if (entries == null)
|
|
// Create an AbstractSet with custom implementations of those methods
|
|
// that can be overriden easily and efficiently.
|
|
entries = new SubMap.NavigableEntrySet();
|
|
return entries;
|
|
}
|
|
|
|
public Entry<K,V> firstEntry()
|
|
{
|
|
Node<K,V> node = lowestGreaterThan(minKey, true);
|
|
if (node == nil || ! keyInRange(node.key))
|
|
return null;
|
|
return node;
|
|
}
|
|
|
|
public K firstKey()
|
|
{
|
|
Entry<K,V> e = firstEntry();
|
|
if (e == null)
|
|
throw new NoSuchElementException();
|
|
return e.getKey();
|
|
}
|
|
|
|
public Entry<K,V> floorEntry(K key)
|
|
{
|
|
Entry<K,V> n = TreeMap.this.floorEntry(key);
|
|
if (n != null && keyInRange(n.getKey()))
|
|
return n;
|
|
return null;
|
|
}
|
|
|
|
public K floorKey(K key)
|
|
{
|
|
K found = TreeMap.this.floorKey(key);
|
|
if (keyInRange(found))
|
|
return found;
|
|
else
|
|
return null;
|
|
}
|
|
|
|
public V get(Object key)
|
|
{
|
|
if (keyInRange((K) key))
|
|
return TreeMap.this.get(key);
|
|
return null;
|
|
}
|
|
|
|
public SortedMap<K,V> headMap(K toKey)
|
|
{
|
|
return headMap(toKey, false);
|
|
}
|
|
|
|
public NavigableMap<K,V> headMap(K toKey, boolean inclusive)
|
|
{
|
|
if (!keyInRange(toKey))
|
|
throw new IllegalArgumentException("Key outside submap range");
|
|
return new SubMap(minKey, (inclusive ?
|
|
successor(getNode(toKey)).key : toKey));
|
|
}
|
|
|
|
public Set<K> keySet()
|
|
{
|
|
if (this.keys == null)
|
|
// Create an AbstractSet with custom implementations of those methods
|
|
// that can be overriden easily and efficiently.
|
|
this.keys = new SubMap.KeySet();
|
|
return this.keys;
|
|
}
|
|
|
|
public Entry<K,V> higherEntry(K key)
|
|
{
|
|
Entry<K,V> n = TreeMap.this.higherEntry(key);
|
|
if (n != null && keyInRange(n.getKey()))
|
|
return n;
|
|
return null;
|
|
}
|
|
|
|
public K higherKey(K key)
|
|
{
|
|
K found = TreeMap.this.higherKey(key);
|
|
if (keyInRange(found))
|
|
return found;
|
|
else
|
|
return null;
|
|
}
|
|
|
|
public Entry<K,V> lastEntry()
|
|
{
|
|
return lowerEntry(maxKey);
|
|
}
|
|
|
|
public K lastKey()
|
|
{
|
|
Entry<K,V> e = lastEntry();
|
|
if (e == null)
|
|
throw new NoSuchElementException();
|
|
return e.getKey();
|
|
}
|
|
|
|
public Entry<K,V> lowerEntry(K key)
|
|
{
|
|
Entry<K,V> n = TreeMap.this.lowerEntry(key);
|
|
if (n != null && keyInRange(n.getKey()))
|
|
return n;
|
|
return null;
|
|
}
|
|
|
|
public K lowerKey(K key)
|
|
{
|
|
K found = TreeMap.this.lowerKey(key);
|
|
if (keyInRange(found))
|
|
return found;
|
|
else
|
|
return null;
|
|
}
|
|
|
|
public NavigableSet<K> navigableKeySet()
|
|
{
|
|
if (this.nKeys == null)
|
|
// Create an AbstractSet with custom implementations of those methods
|
|
// that can be overriden easily and efficiently.
|
|
this.nKeys = new SubMap.NavigableKeySet();
|
|
return this.nKeys;
|
|
}
|
|
|
|
public Entry<K,V> pollFirstEntry()
|
|
{
|
|
Entry<K,V> e = firstEntry();
|
|
if (e != null)
|
|
removeNode((Node<K,V>) e);
|
|
return e;
|
|
}
|
|
|
|
public Entry<K,V> pollLastEntry()
|
|
{
|
|
Entry<K,V> e = lastEntry();
|
|
if (e != null)
|
|
removeNode((Node<K,V>) e);
|
|
return e;
|
|
}
|
|
|
|
public V put(K key, V value)
|
|
{
|
|
if (! keyInRange(key))
|
|
throw new IllegalArgumentException("Key outside range");
|
|
return TreeMap.this.put(key, value);
|
|
}
|
|
|
|
public V remove(Object key)
|
|
{
|
|
if (keyInRange((K)key))
|
|
return TreeMap.this.remove(key);
|
|
return null;
|
|
}
|
|
|
|
public int size()
|
|
{
|
|
Node node = lowestGreaterThan(minKey, true);
|
|
Node max = lowestGreaterThan(maxKey, false);
|
|
int count = 0;
|
|
while (node != max)
|
|
{
|
|
count++;
|
|
node = successor(node);
|
|
}
|
|
return count;
|
|
}
|
|
|
|
public SortedMap<K,V> subMap(K fromKey, K toKey)
|
|
{
|
|
return subMap(fromKey, true, toKey, false);
|
|
}
|
|
|
|
public NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive,
|
|
K toKey, boolean toInclusive)
|
|
{
|
|
if (! keyInRange(fromKey) || ! keyInRange(toKey))
|
|
throw new IllegalArgumentException("key outside range");
|
|
return new SubMap(fromInclusive ? fromKey : successor(getNode(fromKey)).key,
|
|
toInclusive ? successor(getNode(toKey)).key : toKey);
|
|
}
|
|
|
|
public SortedMap<K, V> tailMap(K fromKey)
|
|
{
|
|
return tailMap(fromKey, true);
|
|
}
|
|
|
|
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive)
|
|
{
|
|
if (! keyInRange(fromKey))
|
|
throw new IllegalArgumentException("key outside range");
|
|
return new SubMap(inclusive ? fromKey : successor(getNode(fromKey)).key,
|
|
maxKey);
|
|
}
|
|
|
|
public Collection<V> values()
|
|
{
|
|
if (this.values == null)
|
|
// Create an AbstractCollection with custom implementations of those
|
|
// methods that can be overriden easily and efficiently.
|
|
this.values = new AbstractCollection()
|
|
{
|
|
public int size()
|
|
{
|
|
return SubMap.this.size();
|
|
}
|
|
|
|
public Iterator<V> iterator()
|
|
{
|
|
Node first = lowestGreaterThan(minKey, true);
|
|
Node max = lowestGreaterThan(maxKey, false);
|
|
return new TreeIterator(VALUES, first, max);
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
SubMap.this.clear();
|
|
}
|
|
};
|
|
return this.values;
|
|
}
|
|
|
|
private class KeySet
|
|
extends AbstractSet<K>
|
|
{
|
|
public int size()
|
|
{
|
|
return SubMap.this.size();
|
|
}
|
|
|
|
public Iterator<K> iterator()
|
|
{
|
|
Node first = lowestGreaterThan(minKey, true);
|
|
Node max = lowestGreaterThan(maxKey, false);
|
|
return new TreeIterator(KEYS, first, max);
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
SubMap.this.clear();
|
|
}
|
|
|
|
public boolean contains(Object o)
|
|
{
|
|
if (! keyInRange((K) o))
|
|
return false;
|
|
return getNode((K) o) != nil;
|
|
}
|
|
|
|
public boolean remove(Object o)
|
|
{
|
|
if (! keyInRange((K) o))
|
|
return false;
|
|
Node n = getNode((K) o);
|
|
if (n != nil)
|
|
{
|
|
removeNode(n);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // class SubMap.KeySet
|
|
|
|
private final class NavigableKeySet
|
|
extends KeySet
|
|
implements NavigableSet<K>
|
|
{
|
|
|
|
public K ceiling(K k)
|
|
{
|
|
return SubMap.this.ceilingKey(k);
|
|
}
|
|
|
|
public Comparator<? super K> comparator()
|
|
{
|
|
return comparator;
|
|
}
|
|
|
|
public Iterator<K> descendingIterator()
|
|
{
|
|
return descendingSet().iterator();
|
|
}
|
|
|
|
public NavigableSet<K> descendingSet()
|
|
{
|
|
return new DescendingSet(this);
|
|
}
|
|
|
|
public K first()
|
|
{
|
|
return SubMap.this.firstKey();
|
|
}
|
|
|
|
public K floor(K k)
|
|
{
|
|
return SubMap.this.floorKey(k);
|
|
}
|
|
|
|
public SortedSet<K> headSet(K to)
|
|
{
|
|
return headSet(to, false);
|
|
}
|
|
|
|
public NavigableSet<K> headSet(K to, boolean inclusive)
|
|
{
|
|
return SubMap.this.headMap(to, inclusive).navigableKeySet();
|
|
}
|
|
|
|
public K higher(K k)
|
|
{
|
|
return SubMap.this.higherKey(k);
|
|
}
|
|
|
|
public K last()
|
|
{
|
|
return SubMap.this.lastKey();
|
|
}
|
|
|
|
public K lower(K k)
|
|
{
|
|
return SubMap.this.lowerKey(k);
|
|
}
|
|
|
|
public K pollFirst()
|
|
{
|
|
return SubMap.this.pollFirstEntry().getKey();
|
|
}
|
|
|
|
public K pollLast()
|
|
{
|
|
return SubMap.this.pollLastEntry().getKey();
|
|
}
|
|
|
|
public SortedSet<K> subSet(K from, K to)
|
|
{
|
|
return subSet(from, true, to, false);
|
|
}
|
|
|
|
public NavigableSet<K> subSet(K from, boolean fromInclusive,
|
|
K to, boolean toInclusive)
|
|
{
|
|
return SubMap.this.subMap(from, fromInclusive,
|
|
to, toInclusive).navigableKeySet();
|
|
}
|
|
|
|
public SortedSet<K> tailSet(K from)
|
|
{
|
|
return tailSet(from, true);
|
|
}
|
|
|
|
public NavigableSet<K> tailSet(K from, boolean inclusive)
|
|
{
|
|
return SubMap.this.tailMap(from, inclusive).navigableKeySet();
|
|
}
|
|
|
|
} // class SubMap.NavigableKeySet
|
|
|
|
/**
|
|
* Implementation of {@link #entrySet()}.
|
|
*/
|
|
private class EntrySet
|
|
extends AbstractSet<Entry<K,V>>
|
|
{
|
|
|
|
public int size()
|
|
{
|
|
return SubMap.this.size();
|
|
}
|
|
|
|
public Iterator<Map.Entry<K,V>> iterator()
|
|
{
|
|
Node first = lowestGreaterThan(minKey, true);
|
|
Node max = lowestGreaterThan(maxKey, false);
|
|
return new TreeIterator(ENTRIES, first, max);
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
SubMap.this.clear();
|
|
}
|
|
|
|
public boolean contains(Object o)
|
|
{
|
|
if (! (o instanceof Map.Entry))
|
|
return false;
|
|
Map.Entry<K,V> me = (Map.Entry<K,V>) o;
|
|
K key = me.getKey();
|
|
if (! keyInRange(key))
|
|
return false;
|
|
Node<K,V> n = getNode(key);
|
|
return n != nil && AbstractSet.equals(me.getValue(), n.value);
|
|
}
|
|
|
|
public boolean remove(Object o)
|
|
{
|
|
if (! (o instanceof Map.Entry))
|
|
return false;
|
|
Map.Entry<K,V> me = (Map.Entry<K,V>) o;
|
|
K key = me.getKey();
|
|
if (! keyInRange(key))
|
|
return false;
|
|
Node<K,V> n = getNode(key);
|
|
if (n != nil && AbstractSet.equals(me.getValue(), n.value))
|
|
{
|
|
removeNode(n);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
} // class SubMap.EntrySet
|
|
|
|
private final class NavigableEntrySet
|
|
extends EntrySet
|
|
implements NavigableSet<Entry<K,V>>
|
|
{
|
|
|
|
public Entry<K,V> ceiling(Entry<K,V> e)
|
|
{
|
|
return SubMap.this.ceilingEntry(e.getKey());
|
|
}
|
|
|
|
public Comparator<? super Entry<K,V>> comparator()
|
|
{
|
|
return new Comparator<Entry<K,V>>()
|
|
{
|
|
public int compare(Entry<K,V> t1, Entry<K,V> t2)
|
|
{
|
|
return comparator.compare(t1.getKey(), t2.getKey());
|
|
}
|
|
};
|
|
}
|
|
|
|
public Iterator<Entry<K,V>> descendingIterator()
|
|
{
|
|
return descendingSet().iterator();
|
|
}
|
|
|
|
public NavigableSet<Entry<K,V>> descendingSet()
|
|
{
|
|
return new DescendingSet(this);
|
|
}
|
|
|
|
public Entry<K,V> first()
|
|
{
|
|
return SubMap.this.firstEntry();
|
|
}
|
|
|
|
public Entry<K,V> floor(Entry<K,V> e)
|
|
{
|
|
return SubMap.this.floorEntry(e.getKey());
|
|
}
|
|
|
|
public SortedSet<Entry<K,V>> headSet(Entry<K,V> to)
|
|
{
|
|
return headSet(to, false);
|
|
}
|
|
|
|
public NavigableSet<Entry<K,V>> headSet(Entry<K,V> to, boolean inclusive)
|
|
{
|
|
return (NavigableSet<Entry<K,V>>)
|
|
SubMap.this.headMap(to.getKey(), inclusive).entrySet();
|
|
}
|
|
|
|
public Entry<K,V> higher(Entry<K,V> e)
|
|
{
|
|
return SubMap.this.higherEntry(e.getKey());
|
|
}
|
|
|
|
public Entry<K,V> last()
|
|
{
|
|
return SubMap.this.lastEntry();
|
|
}
|
|
|
|
public Entry<K,V> lower(Entry<K,V> e)
|
|
{
|
|
return SubMap.this.lowerEntry(e.getKey());
|
|
}
|
|
|
|
public Entry<K,V> pollFirst()
|
|
{
|
|
return SubMap.this.pollFirstEntry();
|
|
}
|
|
|
|
public Entry<K,V> pollLast()
|
|
{
|
|
return SubMap.this.pollLastEntry();
|
|
}
|
|
|
|
public SortedSet<Entry<K,V>> subSet(Entry<K,V> from, Entry<K,V> to)
|
|
{
|
|
return subSet(from, true, to, false);
|
|
}
|
|
|
|
public NavigableSet<Entry<K,V>> subSet(Entry<K,V> from, boolean fromInclusive,
|
|
Entry<K,V> to, boolean toInclusive)
|
|
{
|
|
return (NavigableSet<Entry<K,V>>)
|
|
SubMap.this.subMap(from.getKey(), fromInclusive,
|
|
to.getKey(), toInclusive).entrySet();
|
|
}
|
|
|
|
public SortedSet<Entry<K,V>> tailSet(Entry<K,V> from)
|
|
{
|
|
return tailSet(from, true);
|
|
}
|
|
|
|
public NavigableSet<Entry<K,V>> tailSet(Entry<K,V> from, boolean inclusive)
|
|
{
|
|
return (NavigableSet<Entry<K,V>>)
|
|
SubMap.this.tailMap(from.getKey(), inclusive).navigableKeySet();
|
|
}
|
|
|
|
} // class SubMap.NavigableEntrySet
|
|
|
|
} // class SubMap
|
|
|
|
/**
|
|
* Returns the entry associated with the least or lowest key
|
|
* that is greater than or equal to the specified key, or
|
|
* <code>null</code> if there is no such key.
|
|
*
|
|
* @param key the key relative to the returned entry.
|
|
* @return the entry with the least key greater than or equal
|
|
* to the given key, or <code>null</code> if there is
|
|
* no such key.
|
|
* @throws ClassCastException if the specified key can not
|
|
* be compared with those in the map.
|
|
* @throws NullPointerException if the key is <code>null</code>
|
|
* and this map either uses natural
|
|
* ordering or a comparator that does
|
|
* not permit null keys.
|
|
* @since 1.6
|
|
*/
|
|
public Entry<K,V> ceilingEntry(K key)
|
|
{
|
|
Node<K,V> n = lowestGreaterThan(key, false);
|
|
return (n == nil) ? null : n;
|
|
}
|
|
|
|
/**
|
|
* Returns the the least or lowest key that is greater than
|
|
* or equal to the specified key, or <code>null</code> if
|
|
* there is no such key.
|
|
*
|
|
* @param key the key relative to the returned entry.
|
|
* @return the least key greater than or equal to the given key,
|
|
* or <code>null</code> if there is no such key.
|
|
* @throws ClassCastException if the specified key can not
|
|
* be compared with those in the map.
|
|
* @throws NullPointerException if the key is <code>null</code>
|
|
* and this map either uses natural
|
|
* ordering or a comparator that does
|
|
* not permit null keys.
|
|
* @since 1.6
|
|
*/
|
|
public K ceilingKey(K key)
|
|
{
|
|
Entry<K,V> e = ceilingEntry(key);
|
|
return (e == null) ? null : e.getKey();
|
|
}
|
|
|
|
/**
|
|
* Returns a reverse ordered {@link NavigableSet} view of this
|
|
* map's keys. The set is backed by the {@link TreeMap}, so changes
|
|
* in one show up in the other. The set supports element removal,
|
|
* but not element addition.
|
|
*
|
|
* @return a reverse ordered set view of the keys.
|
|
* @since 1.6
|
|
* @see #descendingMap()
|
|
*/
|
|
public NavigableSet<K> descendingKeySet()
|
|
{
|
|
return descendingMap().navigableKeySet();
|
|
}
|
|
|
|
/**
|
|
* Returns a view of the map in reverse order. The descending map
|
|
* is backed by the original map, so that changes affect both maps.
|
|
* Any changes occurring to either map while an iteration is taking
|
|
* place (with the exception of a {@link Iterator#remove()} operation)
|
|
* result in undefined behaviour from the iteration. The ordering
|
|
* of the descending map is the same as for a map with a
|
|
* {@link Comparator} given by {@link Collections#reverseOrder()},
|
|
* and calling {@link #descendingMap()} on the descending map itself
|
|
* results in a view equivalent to the original map.
|
|
*
|
|
* @return a reverse order view of the map.
|
|
* @since 1.6
|
|
*/
|
|
public NavigableMap<K,V> descendingMap()
|
|
{
|
|
if (descendingMap == null)
|
|
descendingMap = new DescendingMap<K,V>(this);
|
|
return descendingMap;
|
|
}
|
|
|
|
/**
|
|
* Returns the entry associated with the least or lowest key
|
|
* in the map, or <code>null</code> if the map is empty.
|
|
*
|
|
* @return the lowest entry, or <code>null</code> if the map
|
|
* is empty.
|
|
* @since 1.6
|
|
*/
|
|
public Entry<K,V> firstEntry()
|
|
{
|
|
Node<K,V> n = firstNode();
|
|
return (n == nil) ? null : n;
|
|
}
|
|
|
|
/**
|
|
* Returns the entry associated with the greatest or highest key
|
|
* that is less than or equal to the specified key, or
|
|
* <code>null</code> if there is no such key.
|
|
*
|
|
* @param key the key relative to the returned entry.
|
|
* @return the entry with the greatest key less than or equal
|
|
* to the given key, or <code>null</code> if there is
|
|
* no such key.
|
|
* @throws ClassCastException if the specified key can not
|
|
* be compared with those in the map.
|
|
* @throws NullPointerException if the key is <code>null</code>
|
|
* and this map either uses natural
|
|
* ordering or a comparator that does
|
|
* not permit null keys.
|
|
* @since 1.6
|
|
*/
|
|
public Entry<K,V> floorEntry(K key)
|
|
{
|
|
Node<K,V> n = highestLessThan(key, true);
|
|
return (n == nil) ? null : n;
|
|
}
|
|
|
|
/**
|
|
* Returns the the greatest or highest key that is less than
|
|
* or equal to the specified key, or <code>null</code> if
|
|
* there is no such key.
|
|
*
|
|
* @param key the key relative to the returned entry.
|
|
* @return the greatest key less than or equal to the given key,
|
|
* or <code>null</code> if there is no such key.
|
|
* @throws ClassCastException if the specified key can not
|
|
* be compared with those in the map.
|
|
* @throws NullPointerException if the key is <code>null</code>
|
|
* and this map either uses natural
|
|
* ordering or a comparator that does
|
|
* not permit null keys.
|
|
* @since 1.6
|
|
*/
|
|
public K floorKey(K key)
|
|
{
|
|
Entry<K,V> e = floorEntry(key);
|
|
return (e == null) ? null : e.getKey();
|
|
}
|
|
|
|
/**
|
|
* Returns the entry associated with the least or lowest key
|
|
* that is strictly greater than the specified key, or
|
|
* <code>null</code> if there is no such key.
|
|
*
|
|
* @param key the key relative to the returned entry.
|
|
* @return the entry with the least key greater than
|
|
* the given key, or <code>null</code> if there is
|
|
* no such key.
|
|
* @throws ClassCastException if the specified key can not
|
|
* be compared with those in the map.
|
|
* @throws NullPointerException if the key is <code>null</code>
|
|
* and this map either uses natural
|
|
* ordering or a comparator that does
|
|
* not permit null keys.
|
|
* @since 1.6
|
|
*/
|
|
public Entry<K,V> higherEntry(K key)
|
|
{
|
|
Node<K,V> n = lowestGreaterThan(key, false, false);
|
|
return (n == nil) ? null : n;
|
|
}
|
|
|
|
/**
|
|
* Returns the the least or lowest key that is strictly
|
|
* greater than the specified key, or <code>null</code> if
|
|
* there is no such key.
|
|
*
|
|
* @param key the key relative to the returned entry.
|
|
* @return the least key greater than the given key,
|
|
* or <code>null</code> if there is no such key.
|
|
* @throws ClassCastException if the specified key can not
|
|
* be compared with those in the map.
|
|
* @throws NullPointerException if the key is <code>null</code>
|
|
* and this map either uses natural
|
|
* ordering or a comparator that does
|
|
* not permit null keys.
|
|
* @since 1.6
|
|
*/
|
|
public K higherKey(K key)
|
|
{
|
|
Entry<K,V> e = higherEntry(key);
|
|
return (e == null) ? null : e.getKey();
|
|
}
|
|
|
|
/**
|
|
* Returns the entry associated with the greatest or highest key
|
|
* in the map, or <code>null</code> if the map is empty.
|
|
*
|
|
* @return the highest entry, or <code>null</code> if the map
|
|
* is empty.
|
|
* @since 1.6
|
|
*/
|
|
public Entry<K,V> lastEntry()
|
|
{
|
|
Node<K,V> n = lastNode();
|
|
return (n == nil) ? null : n;
|
|
}
|
|
|
|
/**
|
|
* Returns the entry associated with the greatest or highest key
|
|
* that is strictly less than the specified key, or
|
|
* <code>null</code> if there is no such key.
|
|
*
|
|
* @param key the key relative to the returned entry.
|
|
* @return the entry with the greatest key less than
|
|
* the given key, or <code>null</code> if there is
|
|
* no such key.
|
|
* @throws ClassCastException if the specified key can not
|
|
* be compared with those in the map.
|
|
* @throws NullPointerException if the key is <code>null</code>
|
|
* and this map either uses natural
|
|
* ordering or a comparator that does
|
|
* not permit null keys.
|
|
* @since 1.6
|
|
*/
|
|
public Entry<K,V> lowerEntry(K key)
|
|
{
|
|
Node<K,V> n = highestLessThan(key);
|
|
return (n == nil) ? null : n;
|
|
}
|
|
|
|
/**
|
|
* Returns the the greatest or highest key that is strictly
|
|
* less than the specified key, or <code>null</code> if
|
|
* there is no such key.
|
|
*
|
|
* @param key the key relative to the returned entry.
|
|
* @return the greatest key less than the given key,
|
|
* or <code>null</code> if there is no such key.
|
|
* @throws ClassCastException if the specified key can not
|
|
* be compared with those in the map.
|
|
* @throws NullPointerException if the key is <code>null</code>
|
|
* and this map either uses natural
|
|
* ordering or a comparator that does
|
|
* not permit null keys.
|
|
* @since 1.6
|
|
*/
|
|
public K lowerKey(K key)
|
|
{
|
|
Entry<K,V> e = lowerEntry(key);
|
|
return (e == null) ? null : e.getKey();
|
|
}
|
|
|
|
/**
|
|
* Returns a {@link NavigableSet} view of this map's keys. The set is
|
|
* backed by the {@link TreeMap}, so changes in one show up in the other.
|
|
* Any changes occurring to either while an iteration is taking
|
|
* place (with the exception of a {@link Iterator#remove()} operation)
|
|
* result in undefined behaviour from the iteration. The ordering
|
|
* The set supports element removal, but not element addition.
|
|
*
|
|
* @return a {@link NavigableSet} view of the keys.
|
|
* @since 1.6
|
|
*/
|
|
public NavigableSet<K> navigableKeySet()
|
|
{
|
|
if (nKeys == null)
|
|
nKeys = new NavigableKeySet();
|
|
return nKeys;
|
|
}
|
|
|
|
/**
|
|
* Removes and returns the entry associated with the least
|
|
* or lowest key in the map, or <code>null</code> if the map
|
|
* is empty.
|
|
*
|
|
* @return the removed first entry, or <code>null</code> if the
|
|
* map is empty.
|
|
* @since 1.6
|
|
*/
|
|
public Entry<K,V> pollFirstEntry()
|
|
{
|
|
Entry<K,V> e = firstEntry();
|
|
if (e != null)
|
|
removeNode((Node<K,V>)e);
|
|
return e;
|
|
}
|
|
|
|
/**
|
|
* Removes and returns the entry associated with the greatest
|
|
* or highest key in the map, or <code>null</code> if the map
|
|
* is empty.
|
|
*
|
|
* @return the removed last entry, or <code>null</code> if the
|
|
* map is empty.
|
|
* @since 1.6
|
|
*/
|
|
public Entry<K,V> pollLastEntry()
|
|
{
|
|
Entry<K,V> e = lastEntry();
|
|
if (e != null)
|
|
removeNode((Node<K,V>)e);
|
|
return e;
|
|
}
|
|
|
|
/**
|
|
* Implementation of {@link #descendingMap()} and associated
|
|
* derivatives. This class provides a view of the
|
|
* original backing map in reverse order, and throws
|
|
* {@link IllegalArgumentException} for attempts to
|
|
* access beyond that range.
|
|
*
|
|
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
|
*/
|
|
private static final class DescendingMap<DK,DV>
|
|
implements NavigableMap<DK,DV>
|
|
{
|
|
|
|
/**
|
|
* The cache for {@link #entrySet()}.
|
|
*/
|
|
private Set<Map.Entry<DK,DV>> entries;
|
|
|
|
/**
|
|
* The cache for {@link #keySet()}.
|
|
*/
|
|
private Set<DK> keys;
|
|
|
|
/**
|
|
* The cache for {@link #navigableKeySet()}.
|
|
*/
|
|
private NavigableSet<DK> nKeys;
|
|
|
|
/**
|
|
* The cache for {@link #values()}.
|
|
*/
|
|
private Collection<DV> values;
|
|
|
|
/**
|
|
* The backing {@link NavigableMap}.
|
|
*/
|
|
private NavigableMap<DK,DV> map;
|
|
|
|
/**
|
|
* Create a {@link DescendingMap} around the specified
|
|
* map.
|
|
*
|
|
* @param map the map to wrap.
|
|
*/
|
|
public DescendingMap(NavigableMap<DK,DV> map)
|
|
{
|
|
this.map = map;
|
|
}
|
|
|
|
public Map.Entry<DK,DV> ceilingEntry(DK key)
|
|
{
|
|
return map.floorEntry(key);
|
|
}
|
|
|
|
public DK ceilingKey(DK key)
|
|
{
|
|
return map.floorKey(key);
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
map.clear();
|
|
}
|
|
|
|
public Comparator<? super DK> comparator()
|
|
{
|
|
return Collections.reverseOrder(map.comparator());
|
|
}
|
|
|
|
public boolean containsKey(Object o)
|
|
{
|
|
return map.containsKey(o);
|
|
}
|
|
|
|
public boolean containsValue(Object o)
|
|
{
|
|
return map.containsValue(o);
|
|
}
|
|
|
|
public NavigableSet<DK> descendingKeySet()
|
|
{
|
|
return descendingMap().navigableKeySet();
|
|
}
|
|
|
|
public NavigableMap<DK,DV> descendingMap()
|
|
{
|
|
return map;
|
|
}
|
|
|
|
public Set<Entry<DK,DV>> entrySet()
|
|
{
|
|
if (entries == null)
|
|
entries =
|
|
new DescendingSet<Entry<DK,DV>>((NavigableSet<Entry<DK,DV>>)
|
|
map.entrySet());
|
|
return entries;
|
|
}
|
|
|
|
public boolean equals(Object o)
|
|
{
|
|
return map.equals(o);
|
|
}
|
|
|
|
public Entry<DK,DV> firstEntry()
|
|
{
|
|
return map.lastEntry();
|
|
}
|
|
|
|
public DK firstKey()
|
|
{
|
|
return map.lastKey();
|
|
}
|
|
|
|
public Entry<DK,DV> floorEntry(DK key)
|
|
{
|
|
return map.ceilingEntry(key);
|
|
}
|
|
|
|
public DK floorKey(DK key)
|
|
{
|
|
return map.ceilingKey(key);
|
|
}
|
|
|
|
public DV get(Object key)
|
|
{
|
|
return map.get(key);
|
|
}
|
|
|
|
public int hashCode()
|
|
{
|
|
return map.hashCode();
|
|
}
|
|
|
|
public SortedMap<DK,DV> headMap(DK toKey)
|
|
{
|
|
return headMap(toKey, false);
|
|
}
|
|
|
|
public NavigableMap<DK,DV> headMap(DK toKey, boolean inclusive)
|
|
{
|
|
return new DescendingMap(map.tailMap(toKey, inclusive));
|
|
}
|
|
|
|
public Entry<DK,DV> higherEntry(DK key)
|
|
{
|
|
return map.lowerEntry(key);
|
|
}
|
|
|
|
public DK higherKey(DK key)
|
|
{
|
|
return map.lowerKey(key);
|
|
}
|
|
|
|
public Set<DK> keySet()
|
|
{
|
|
if (keys == null)
|
|
keys = new DescendingSet<DK>(map.navigableKeySet());
|
|
return keys;
|
|
}
|
|
|
|
public boolean isEmpty()
|
|
{
|
|
return map.isEmpty();
|
|
}
|
|
|
|
public Entry<DK,DV> lastEntry()
|
|
{
|
|
return map.firstEntry();
|
|
}
|
|
|
|
public DK lastKey()
|
|
{
|
|
return map.firstKey();
|
|
}
|
|
|
|
public Entry<DK,DV> lowerEntry(DK key)
|
|
{
|
|
return map.higherEntry(key);
|
|
}
|
|
|
|
public DK lowerKey(DK key)
|
|
{
|
|
return map.higherKey(key);
|
|
}
|
|
|
|
public NavigableSet<DK> navigableKeySet()
|
|
{
|
|
if (nKeys == null)
|
|
nKeys = new DescendingSet<DK>(map.navigableKeySet());
|
|
return nKeys;
|
|
}
|
|
|
|
public Entry<DK,DV> pollFirstEntry()
|
|
{
|
|
return pollLastEntry();
|
|
}
|
|
|
|
public Entry<DK,DV> pollLastEntry()
|
|
{
|
|
return pollFirstEntry();
|
|
}
|
|
|
|
public DV put(DK key, DV value)
|
|
{
|
|
return map.put(key, value);
|
|
}
|
|
|
|
public void putAll(Map<? extends DK, ? extends DV> m)
|
|
{
|
|
map.putAll(m);
|
|
}
|
|
|
|
public DV remove(Object key)
|
|
{
|
|
return map.remove(key);
|
|
}
|
|
|
|
public int size()
|
|
{
|
|
return map.size();
|
|
}
|
|
|
|
public SortedMap<DK,DV> subMap(DK fromKey, DK toKey)
|
|
{
|
|
return subMap(fromKey, true, toKey, false);
|
|
}
|
|
|
|
public NavigableMap<DK,DV> subMap(DK fromKey, boolean fromInclusive,
|
|
DK toKey, boolean toInclusive)
|
|
{
|
|
return new DescendingMap(map.subMap(fromKey, fromInclusive,
|
|
toKey, toInclusive));
|
|
}
|
|
|
|
public SortedMap<DK,DV> tailMap(DK fromKey)
|
|
{
|
|
return tailMap(fromKey, true);
|
|
}
|
|
|
|
public NavigableMap<DK,DV> tailMap(DK fromKey, boolean inclusive)
|
|
{
|
|
return new DescendingMap(map.headMap(fromKey, inclusive));
|
|
}
|
|
|
|
public String toString()
|
|
{
|
|
CPStringBuilder r = new CPStringBuilder("{");
|
|
final Iterator<Entry<DK,DV>> it = entrySet().iterator();
|
|
while (it.hasNext())
|
|
{
|
|
final Entry<DK,DV> e = it.next();
|
|
r.append(e.getKey());
|
|
r.append('=');
|
|
r.append(e.getValue());
|
|
r.append(", ");
|
|
}
|
|
r.replace(r.length() - 2, r.length(), "}");
|
|
return r.toString();
|
|
}
|
|
|
|
public Collection<DV> values()
|
|
{
|
|
if (values == null)
|
|
// Create an AbstractCollection with custom implementations of those
|
|
// methods that can be overriden easily and efficiently.
|
|
values = new AbstractCollection()
|
|
{
|
|
public int size()
|
|
{
|
|
return DescendingMap.this.size();
|
|
}
|
|
|
|
public Iterator<DV> iterator()
|
|
{
|
|
return new Iterator<DV>()
|
|
{
|
|
/** The last Entry returned by a next() call. */
|
|
private Entry<DK,DV> last;
|
|
|
|
/** The next entry that should be returned by next(). */
|
|
private Entry<DK,DV> next = firstEntry();
|
|
|
|
public boolean hasNext()
|
|
{
|
|
return next != null;
|
|
}
|
|
|
|
public DV next()
|
|
{
|
|
if (next == null)
|
|
throw new NoSuchElementException();
|
|
last = next;
|
|
next = higherEntry(last.getKey());
|
|
|
|
return last.getValue();
|
|
}
|
|
|
|
public void remove()
|
|
{
|
|
if (last == null)
|
|
throw new IllegalStateException();
|
|
|
|
DescendingMap.this.remove(last.getKey());
|
|
last = null;
|
|
}
|
|
};
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
DescendingMap.this.clear();
|
|
}
|
|
};
|
|
return values;
|
|
}
|
|
|
|
} // class DescendingMap
|
|
|
|
/**
|
|
* Implementation of {@link #keySet()}.
|
|
*/
|
|
private class KeySet
|
|
extends AbstractSet<K>
|
|
{
|
|
|
|
public int size()
|
|
{
|
|
return size;
|
|
}
|
|
|
|
public Iterator<K> iterator()
|
|
{
|
|
return new TreeIterator(KEYS);
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
TreeMap.this.clear();
|
|
}
|
|
|
|
public boolean contains(Object o)
|
|
{
|
|
return containsKey(o);
|
|
}
|
|
|
|
public boolean remove(Object key)
|
|
{
|
|
Node<K,V> n = getNode((K) key);
|
|
if (n == nil)
|
|
return false;
|
|
removeNode(n);
|
|
return true;
|
|
}
|
|
} // class KeySet
|
|
|
|
/**
|
|
* Implementation of {@link #navigableKeySet()}.
|
|
*
|
|
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
|
*/
|
|
private final class NavigableKeySet
|
|
extends KeySet
|
|
implements NavigableSet<K>
|
|
{
|
|
|
|
public K ceiling(K k)
|
|
{
|
|
return ceilingKey(k);
|
|
}
|
|
|
|
public Comparator<? super K> comparator()
|
|
{
|
|
return comparator;
|
|
}
|
|
|
|
public Iterator<K> descendingIterator()
|
|
{
|
|
return descendingSet().iterator();
|
|
}
|
|
|
|
public NavigableSet<K> descendingSet()
|
|
{
|
|
return new DescendingSet<K>(this);
|
|
}
|
|
|
|
public K first()
|
|
{
|
|
return firstKey();
|
|
}
|
|
|
|
public K floor(K k)
|
|
{
|
|
return floorKey(k);
|
|
}
|
|
|
|
public SortedSet<K> headSet(K to)
|
|
{
|
|
return headSet(to, false);
|
|
}
|
|
|
|
public NavigableSet<K> headSet(K to, boolean inclusive)
|
|
{
|
|
return headMap(to, inclusive).navigableKeySet();
|
|
}
|
|
|
|
public K higher(K k)
|
|
{
|
|
return higherKey(k);
|
|
}
|
|
|
|
public K last()
|
|
{
|
|
return lastKey();
|
|
}
|
|
|
|
public K lower(K k)
|
|
{
|
|
return lowerKey(k);
|
|
}
|
|
|
|
public K pollFirst()
|
|
{
|
|
return pollFirstEntry().getKey();
|
|
}
|
|
|
|
public K pollLast()
|
|
{
|
|
return pollLastEntry().getKey();
|
|
}
|
|
|
|
public SortedSet<K> subSet(K from, K to)
|
|
{
|
|
return subSet(from, true, to, false);
|
|
}
|
|
|
|
public NavigableSet<K> subSet(K from, boolean fromInclusive,
|
|
K to, boolean toInclusive)
|
|
{
|
|
return subMap(from, fromInclusive,
|
|
to, toInclusive).navigableKeySet();
|
|
}
|
|
|
|
public SortedSet<K> tailSet(K from)
|
|
{
|
|
return tailSet(from, true);
|
|
}
|
|
|
|
public NavigableSet<K> tailSet(K from, boolean inclusive)
|
|
{
|
|
return tailMap(from, inclusive).navigableKeySet();
|
|
}
|
|
|
|
|
|
} // class NavigableKeySet
|
|
|
|
/**
|
|
* Implementation of {@link #descendingSet()} and associated
|
|
* derivatives. This class provides a view of the
|
|
* original backing set in reverse order, and throws
|
|
* {@link IllegalArgumentException} for attempts to
|
|
* access beyond that range.
|
|
*
|
|
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
|
*/
|
|
private static final class DescendingSet<D>
|
|
implements NavigableSet<D>
|
|
{
|
|
|
|
/**
|
|
* The backing {@link NavigableSet}.
|
|
*/
|
|
private NavigableSet<D> set;
|
|
|
|
/**
|
|
* Create a {@link DescendingSet} around the specified
|
|
* set.
|
|
*
|
|
* @param map the set to wrap.
|
|
*/
|
|
public DescendingSet(NavigableSet<D> set)
|
|
{
|
|
this.set = set;
|
|
}
|
|
|
|
public boolean add(D e)
|
|
{
|
|
return set.add(e);
|
|
}
|
|
|
|
public boolean addAll(Collection<? extends D> c)
|
|
{
|
|
return set.addAll(c);
|
|
}
|
|
|
|
public D ceiling(D e)
|
|
{
|
|
return set.floor(e);
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
set.clear();
|
|
}
|
|
|
|
public Comparator<? super D> comparator()
|
|
{
|
|
return Collections.reverseOrder(set.comparator());
|
|
}
|
|
|
|
public boolean contains(Object o)
|
|
{
|
|
return set.contains(o);
|
|
}
|
|
|
|
public boolean containsAll(Collection<?> c)
|
|
{
|
|
return set.containsAll(c);
|
|
}
|
|
|
|
public Iterator<D> descendingIterator()
|
|
{
|
|
return descendingSet().iterator();
|
|
}
|
|
|
|
public NavigableSet<D> descendingSet()
|
|
{
|
|
return set;
|
|
}
|
|
|
|
public boolean equals(Object o)
|
|
{
|
|
return set.equals(o);
|
|
}
|
|
|
|
public D first()
|
|
{
|
|
return set.last();
|
|
}
|
|
|
|
public D floor(D e)
|
|
{
|
|
return set.ceiling(e);
|
|
}
|
|
|
|
public int hashCode()
|
|
{
|
|
return set.hashCode();
|
|
}
|
|
|
|
public SortedSet<D> headSet(D to)
|
|
{
|
|
return headSet(to, false);
|
|
}
|
|
|
|
public NavigableSet<D> headSet(D to, boolean inclusive)
|
|
{
|
|
return new DescendingSet(set.tailSet(to, inclusive));
|
|
}
|
|
|
|
public D higher(D e)
|
|
{
|
|
return set.lower(e);
|
|
}
|
|
|
|
public boolean isEmpty()
|
|
{
|
|
return set.isEmpty();
|
|
}
|
|
|
|
public Iterator<D> iterator()
|
|
{
|
|
return new Iterator<D>()
|
|
{
|
|
|
|
/** The last element returned by a next() call. */
|
|
private D last;
|
|
|
|
/** The next element that should be returned by next(). */
|
|
private D next = first();
|
|
|
|
public boolean hasNext()
|
|
{
|
|
return next != null;
|
|
}
|
|
|
|
public D next()
|
|
{
|
|
if (next == null)
|
|
throw new NoSuchElementException();
|
|
last = next;
|
|
next = higher(last);
|
|
|
|
return last;
|
|
}
|
|
|
|
public void remove()
|
|
{
|
|
if (last == null)
|
|
throw new IllegalStateException();
|
|
|
|
DescendingSet.this.remove(last);
|
|
last = null;
|
|
}
|
|
};
|
|
}
|
|
|
|
public D last()
|
|
{
|
|
return set.first();
|
|
}
|
|
|
|
public D lower(D e)
|
|
{
|
|
return set.higher(e);
|
|
}
|
|
|
|
public D pollFirst()
|
|
{
|
|
return set.pollLast();
|
|
}
|
|
|
|
public D pollLast()
|
|
{
|
|
return set.pollFirst();
|
|
}
|
|
|
|
public boolean remove(Object o)
|
|
{
|
|
return set.remove(o);
|
|
}
|
|
|
|
public boolean removeAll(Collection<?> c)
|
|
{
|
|
return set.removeAll(c);
|
|
}
|
|
|
|
public boolean retainAll(Collection<?> c)
|
|
{
|
|
return set.retainAll(c);
|
|
}
|
|
|
|
public int size()
|
|
{
|
|
return set.size();
|
|
}
|
|
|
|
public SortedSet<D> subSet(D from, D to)
|
|
{
|
|
return subSet(from, true, to, false);
|
|
}
|
|
|
|
public NavigableSet<D> subSet(D from, boolean fromInclusive,
|
|
D to, boolean toInclusive)
|
|
{
|
|
return new DescendingSet(set.subSet(from, fromInclusive,
|
|
to, toInclusive));
|
|
}
|
|
|
|
public SortedSet<D> tailSet(D from)
|
|
{
|
|
return tailSet(from, true);
|
|
}
|
|
|
|
public NavigableSet<D> tailSet(D from, boolean inclusive)
|
|
{
|
|
return new DescendingSet(set.headSet(from, inclusive));
|
|
}
|
|
|
|
public Object[] toArray()
|
|
{
|
|
D[] array = (D[]) set.toArray();
|
|
Arrays.sort(array, comparator());
|
|
return array;
|
|
}
|
|
|
|
public <T> T[] toArray(T[] a)
|
|
{
|
|
T[] array = set.toArray(a);
|
|
Arrays.sort(array, (Comparator<? super T>) comparator());
|
|
return array;
|
|
}
|
|
|
|
public String toString()
|
|
{
|
|
CPStringBuilder r = new CPStringBuilder("[");
|
|
final Iterator<D> it = iterator();
|
|
while (it.hasNext())
|
|
{
|
|
final D o = it.next();
|
|
if (o == this)
|
|
r.append("<this>");
|
|
else
|
|
r.append(o);
|
|
r.append(", ");
|
|
}
|
|
r.replace(r.length() - 2, r.length(), "]");
|
|
return r.toString();
|
|
}
|
|
|
|
} // class DescendingSet
|
|
|
|
private class EntrySet
|
|
extends AbstractSet<Entry<K,V>>
|
|
{
|
|
public int size()
|
|
{
|
|
return size;
|
|
}
|
|
|
|
public Iterator<Map.Entry<K,V>> iterator()
|
|
{
|
|
return new TreeIterator(ENTRIES);
|
|
}
|
|
|
|
public void clear()
|
|
{
|
|
TreeMap.this.clear();
|
|
}
|
|
|
|
public boolean contains(Object o)
|
|
{
|
|
if (! (o instanceof Map.Entry))
|
|
return false;
|
|
Map.Entry<K,V> me = (Map.Entry<K,V>) o;
|
|
Node<K,V> n = getNode(me.getKey());
|
|
return n != nil && AbstractSet.equals(me.getValue(), n.value);
|
|
}
|
|
|
|
public boolean remove(Object o)
|
|
{
|
|
if (! (o instanceof Map.Entry))
|
|
return false;
|
|
Map.Entry<K,V> me = (Map.Entry<K,V>) o;
|
|
Node<K,V> n = getNode(me.getKey());
|
|
if (n != nil && AbstractSet.equals(me.getValue(), n.value))
|
|
{
|
|
removeNode(n);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private final class NavigableEntrySet
|
|
extends EntrySet
|
|
implements NavigableSet<Entry<K,V>>
|
|
{
|
|
|
|
public Entry<K,V> ceiling(Entry<K,V> e)
|
|
{
|
|
return ceilingEntry(e.getKey());
|
|
}
|
|
|
|
public Comparator<? super Entry<K,V>> comparator()
|
|
{
|
|
return new Comparator<Entry<K,V>>()
|
|
{
|
|
public int compare(Entry<K,V> t1, Entry<K,V> t2)
|
|
{
|
|
return comparator.compare(t1.getKey(), t2.getKey());
|
|
}
|
|
};
|
|
}
|
|
|
|
public Iterator<Entry<K,V>> descendingIterator()
|
|
{
|
|
return descendingSet().iterator();
|
|
}
|
|
|
|
public NavigableSet<Entry<K,V>> descendingSet()
|
|
{
|
|
return new DescendingSet(this);
|
|
}
|
|
|
|
public Entry<K,V> first()
|
|
{
|
|
return firstEntry();
|
|
}
|
|
|
|
public Entry<K,V> floor(Entry<K,V> e)
|
|
{
|
|
return floorEntry(e.getKey());
|
|
}
|
|
|
|
public SortedSet<Entry<K,V>> headSet(Entry<K,V> to)
|
|
{
|
|
return headSet(to, false);
|
|
}
|
|
|
|
public NavigableSet<Entry<K,V>> headSet(Entry<K,V> to, boolean inclusive)
|
|
{
|
|
return (NavigableSet<Entry<K,V>>) headMap(to.getKey(), inclusive).entrySet();
|
|
}
|
|
|
|
public Entry<K,V> higher(Entry<K,V> e)
|
|
{
|
|
return higherEntry(e.getKey());
|
|
}
|
|
|
|
public Entry<K,V> last()
|
|
{
|
|
return lastEntry();
|
|
}
|
|
|
|
public Entry<K,V> lower(Entry<K,V> e)
|
|
{
|
|
return lowerEntry(e.getKey());
|
|
}
|
|
|
|
public Entry<K,V> pollFirst()
|
|
{
|
|
return pollFirstEntry();
|
|
}
|
|
|
|
public Entry<K,V> pollLast()
|
|
{
|
|
return pollLastEntry();
|
|
}
|
|
|
|
public SortedSet<Entry<K,V>> subSet(Entry<K,V> from, Entry<K,V> to)
|
|
{
|
|
return subSet(from, true, to, false);
|
|
}
|
|
|
|
public NavigableSet<Entry<K,V>> subSet(Entry<K,V> from, boolean fromInclusive,
|
|
Entry<K,V> to, boolean toInclusive)
|
|
{
|
|
return (NavigableSet<Entry<K,V>>) subMap(from.getKey(), fromInclusive,
|
|
to.getKey(), toInclusive).entrySet();
|
|
}
|
|
|
|
public SortedSet<Entry<K,V>> tailSet(Entry<K,V> from)
|
|
{
|
|
return tailSet(from, true);
|
|
}
|
|
|
|
public NavigableSet<Entry<K,V>> tailSet(Entry<K,V> from, boolean inclusive)
|
|
{
|
|
return (NavigableSet<Entry<K,V>>) tailMap(from.getKey(), inclusive).navigableKeySet();
|
|
}
|
|
|
|
} // class NavigableEntrySet
|
|
|
|
} // class TreeMap
|