Java集合详解
.loopLine, .messageLine0 { marker-end: “url(#arrowhead)” }
@font-face { font-family: octicons-link; src: url(“data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcEq9taGVhZAAAAsgAAAA0AAAANgh4a91oaGVhAAADCAAAABoAAAAkCA8DRGhtdHgAAAL8AAAADAAAAAwGAACfbG9jYQAAAsAAAAAIAAAACABiATBtYXhwAAACqAAAABgAAAAgAA8ASm5hbWUAAAToAAABQgAAAlXu73sOcG9zdAAABiwAAAAeAAAAME3QpOBwcmVwAAAEbAAAAHYAAAB/aFGpk3jaTY6xa8JAGMW/O62BDi0tJLYQincXEypYIiGJjSgHniQ6umTsUEyLm5BV6NDBP8Tpts6F0v+k/0an2i+itHDw3v2+9+DBKTzsJNnWJNTgHEy4BgG3EMI9DCEDOGEXzDADU5hBKMIgNPZqoD3SilVaXZCER3/I7AtxEJLtzzuZfI+VVkprxTlXShWKb3TBecG11rwoNlmmn1P2WYcJczl32etSpKnziC7lQyWe1smVPy/Lt7Kc+0vWY/gAgIIEqAN9we0pwKXreiMasxvabDQMM4riO+qxM2ogwDGOZTXxwxDiycQIcoYFBLj5K3EIaSctAq2kTYiw+ymhce7vwM9jSqO8JyVd5RH9gyTt2+J/yUmYlIR0s04n6+7Vm1ozezUeLEaUjhaDSuXHwVRgvLJn1tQ7xiuVv/ocTRF42mNgZGBgYGbwZOBiAAFGJBIMAAizAFoAAABiAGIAznjaY2BkYGAA4in8zwXi+W2+MjCzMIDApSwvXzC97Z4Ig8N/BxYGZgcgl52BCSQKAA3jCV8CAABfAAAAAAQAAEB42mNgZGBg4f3vACQZQABIMjKgAmYAKEgBXgAAeNpjYGY6wTiBgZWBg2kmUxoDA4MPhGZMYzBi1AHygVLYQUCaawqDA4PChxhmh/8ODDEsvAwHgMKMIDnGL0x7gJQCAwMAJd4MFwAAAHjaY2BgYGaA4DAGRgYQkAHyGMF8NgYrIM3JIAGVYYDT+AEjAwuDFpBmA9KMDEwMCh9i/v8H8sH0/4dQc1iAmAkALaUKLgAAAHjaTY9LDsIgEIbtgqHUPpDi3gPoBVyRTmTddOmqTXThEXqrob2gQ1FjwpDvfwCBdmdXC5AVKFu3e5MfNFJ29KTQT48Ob9/lqYwOGZxeUelN2U2R6+cArgtCJpauW7UQBqnFkUsjAY/kOU1cP+DAgvxwn1chZDwUbd6CFimGXwzwF6tPbFIcjEl+vvmM/byA48e6tWrKArm4ZJlCbdsrxksL1AwWn/yBSJKpYbq8AXaaTb8AAHja28jAwOC00ZrBeQNDQOWO//sdBBgYGRiYWYAEELEwMTE4uzo5Zzo5b2BxdnFOcALxNjA6b2ByTswC8jYwg0VlNuoCTWAMqNzMzsoK1rEhNqByEyerg5PMJlYuVueETKcd/89uBpnpvIEVomeHLoMsAAe1Id4AAAAAAAB42oWQT07CQBTGv0JBhagk7HQzKxca2sJCE1hDt4QF+9JOS0nbaaYDCQfwCJ7Au3AHj+LO13FMmm6cl7785vven0kBjHCBhfpYuNa5Ph1c0e2Xu3jEvWG7UdPDLZ4N92nOm+EBXuAbHmIMSRMs+4aUEd4Nd3CHD8NdvOLTsA2GL8M9PODbcL+hD7C1xoaHeLJSEao0FEW14ckxC+TU8TxvsY6X0eLPmRhry2WVioLpkrbp84LLQPGI7c6sOiUzpWIWS5GzlSgUzzLBSikOPFTOXqly7rqx0Z1Q5BAIoZBSFihQYQOOBEdkCOgXTOHA07HAGjGWiIjaPZNW13/+lm6S9FT7rLHFJ6fQbkATOG1j2OFMucKJJsxIVfQORl+9Jyda6Sl1dUYhSCm1dyClfoeDve4qMYdLEbfqHf3O/AdDumsjAAB42mNgYoAAZQYjBmyAGYQZmdhL8zLdDEydARfoAqIAAAABAAMABwAKABMAB///AA8AAQAAAAAAAAAAAAAAAAABAAAAAA==”) format(“woff”) }
.markdown-body { -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; color: rgba(36, 41, 46, 1); font-family: -apple-system, BlinkMacSystemFont, “Segoe UI”, Helvetica, Arial, sans-serif, “Apple Color Emoji”, “Segoe UI Emoji”, “Segoe UI Symbol”; line-height: 1.5; word-wrap: break-word }
.markdown-body .pl-c { color: rgba(106, 115, 125, 1) }
.markdown-body .pl-c1, .markdown-body .pl-s .pl-v { color: rgba(0, 92, 197, 1) }
.markdown-body .pl-e, .markdown-body .pl-en { color: rgba(111, 66, 193, 1) }
.markdown-body .pl-s .pl-s1, .markdown-body .pl-smi { color: rgba(36, 41, 46, 1) }
.markdown-body .pl-ent { color: rgba(34, 134, 58, 1) }
.markdown-body .pl-k { color: rgba(215, 58, 73, 1) }
.markdown-body .pl-pds, .markdown-body .pl-s, .markdown-body .pl-s .pl-pse .pl-s1, .markdown-body .pl-sr, .markdown-body .pl-sr .pl-cce, .markdown-body .pl-sr .pl-sra, .markdown-body .pl-sr .pl-sre { color: rgba(3, 47, 98, 1) }
.markdown-body .pl-smw, .markdown-body .pl-v { color: rgba(227, 98, 9, 1) }
.markdown-body .pl-bu { color: rgba(179, 29, 40, 1) }
.markdown-body .pl-ii { color: rgba(250, 251, 252, 1); background-color: rgba(179, 29, 40, 1) }
.markdown-body .pl-c2 { color: rgba(250, 251, 252, 1); background-color: rgba(215, 58, 73, 1) }
.markdown-body .pl-c2::before { content: “^M” }
.markdown-body .pl-sr .pl-cce { font-weight: 700; color: rgba(34, 134, 58, 1) }
.markdown-body .pl-ml { color: rgba(115, 92, 15, 1) }
.markdown-body .pl-mh, .markdown-body .pl-mh .pl-en, .markdown-body .pl-ms { font-weight: 700; color: rgba(0, 92, 197, 1) }
.markdown-body .pl-mi { font-style: italic; color: rgba(36, 41, 46, 1) }
.markdown-body .pl-mb { font-weight: 700; color: rgba(36, 41, 46, 1) }
.markdown-body .pl-md { color: rgba(179, 29, 40, 1); background-color: rgba(255, 238, 240, 1) }
.markdown-body .pl-mi1 { color: rgba(34, 134, 58, 1); background-color: rgba(240, 255, 244, 1) }
.markdown-body .pl-mc { color: rgba(227, 98, 9, 1); background-color: rgba(255, 235, 218, 1) }
.markdown-body .pl-mi2 { color: rgba(246, 248, 250, 1); background-color: rgba(0, 92, 197, 1) }
.markdown-body .pl-mdr { font-weight: 700; color: rgba(111, 66, 193, 1) }
.markdown-body .pl-ba { color: rgba(88, 96, 105, 1) }
.markdown-body .pl-sg { color: rgba(149, 157, 165, 1) }
.markdown-body .pl-corl { text-decoration: underline; color: rgba(3, 47, 98, 1) }
.markdown-body .octicon { display: inline-block; fill: currentColor; vertical-align: text-bottom }
.markdown-body hr::after, .markdown-body hr::before, .markdown-body::after, .markdown-body::before { display: table; content: “” }
.markdown-body a { background-color: rgba(0, 0, 0, 0); -webkit-text-decoration-skip: objects; color: rgba(3, 102, 214, 1); text-decoration: none }
.markdown-body a:active, .markdown-body a:hover { outline-width: 0 }
.markdown-body h1 { margin: 0.67em 0 }
.markdown-body img { border-style: none }
.markdown-body svg:not(:root) { overflow: hidden }
.markdown-body hr { box-sizing: content-box }
.markdown-body input { margin: 0; overflow: visible; font-family: inherit; font-size: inherit; line-height: inherit }
.markdown-body [type=”checkbox”] { box-sizing: border-box; padding: 0 }
.markdown-body * { box-sizing: border-box }
.markdown-body a:hover { text-decoration: underline }
.markdown-body strong { font-weight: 600 }
.markdown-body td, .markdown-body th { padding: 0 }
.markdown-body blockquote { margin: 0 }
.markdown-body ol ol, .markdown-body ul ol { list-style-type: lower-roman }
.markdown-body ol ol ol, .markdown-body ol ul ol, .markdown-body ul ol ol, .markdown-body ul ul ol { list-style-type: lower-alpha }
.markdown-body .task-list-item, ul.table-of-contents { list-style-type: none }
.markdown-body dd { margin-left: 0 }
.markdown-body code { font-family: SFMono-Regular, Consolas, “Liberation Mono”, Menlo, Courier, monospace }
.markdown-body pre { font: 12px SFMono-Regular, Consolas, “Liberation Mono”, Menlo, Courier, monospace; word-wrap: normal }
.markdown-body .pl-0 { padding-left: 0 !important }
.markdown-body .pl-1 { padding-left: 4px !important }
.markdown-body .pl-2 { padding-left: 8px !important }
.markdown-body .pl-3 { padding-left: 16px !important }
.markdown-body .pl-4 { padding-left: 24px !important }
.markdown-body .pl-5 { padding-left: 32px !important }
.markdown-body .pl-6 { padding-left: 40px !important }
.markdown-body>:first-child { margin-top: 0 !important }
.markdown-body>:last-child { margin-bottom: 0 !important }
.markdown-body a:not([href]) { color: inherit; text-decoration: none }
.markdown-body .anchor { float: left; padding-right: 4px; margin-left: -20px; line-height: 1 }
.markdown-body .anchor:focus { outline: 0 }
.markdown-body blockquote, .markdown-body dl, .markdown-body ol, .markdown-body p, .markdown-body pre, .markdown-body table, .markdown-body ul { margin-top: 0; margin-bottom: 16px }
.markdown-body hr { overflow: hidden; background: rgba(225, 228, 232, 1); height: 0.25em; padding: 0; margin: 24px 0; border: 0 }
.markdown-body blockquote { padding: 0 1em; color: rgba(106, 115, 125, 1); border-left: 0.25em solid rgba(223, 226, 229, 1) }
.markdown-body h1, .markdown-body h2 { padding-bottom: 0.3em; border-bottom: 1px solid rgba(234, 236, 239, 1) }
.markdown-body blockquote>:first-child { margin-top: 0 }
.markdown-body blockquote>:last-child { margin-bottom: 0 }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { margin-top: 24px; margin-bottom: 16px; font-weight: 600; line-height: 1.25 }
.markdown-body h1 .octicon-link, .markdown-body h2 .octicon-link, .markdown-body h3 .octicon-link, .markdown-body h4 .octicon-link, .markdown-body h5 .octicon-link, .markdown-body h6 .octicon-link { color: rgba(27, 31, 35, 1); vertical-align: middle; visibility: hidden }
.markdown-body h1:hover .anchor, .markdown-body h2:hover .anchor, .markdown-body h3:hover .anchor, .markdown-body h4:hover .anchor, .markdown-body h5:hover .anchor, .markdown-body h6:hover .anchor { text-decoration: none }
.markdown-body h1:hover .anchor .octicon-link, .markdown-body h2:hover .anchor .octicon-link, .markdown-body h3:hover .anchor .octicon-link, .markdown-body h4:hover .anchor .octicon-link, .markdown-body h5:hover .anchor .octicon-link, .markdown-body h6:hover .anchor .octicon-link { visibility: visible }
.markdown-body h6 { color: rgba(106, 115, 125, 1) }
.markdown-body ol, .markdown-body ul { padding-left: 2em }
.markdown-body ol ol, .markdown-body ol ul, .markdown-body ul ol, .markdown-body ul ul { margin-top: 0; margin-bottom: 0 }
.markdown-body li>p { margin-top: 16px }
.markdown-body li+li { margin-top: 0.25em }
.markdown-body dl { padding: 0 }
.markdown-body dl dt { padding: 0; margin-top: 16px; font-size: 1em; font-style: italic; font-weight: 600 }
.markdown-body dl dd { padding: 0 16px; margin-bottom: 16px }
.markdown-body table th { font-weight: 600 }
.markdown-body table td, .markdown-body table th { padding: 6px 13px; border: 1px solid rgba(223, 226, 229, 1) }
.markdown-body table tr { background-color: rgba(255, 255, 255, 1); border-top: 1px solid rgba(198, 203, 209, 1) }
.markdown-body table tr:nth-child(2n) { background-color: rgba(246, 248, 250, 1) }
.markdown-body img { max-width: 100%; box-sizing: content-box; background-color: rgba(255, 255, 255, 1) }
.markdown-body code { padding: 0.2em 0; margin: 0; font-size: 85%; background-color: rgba(27, 31, 35, 0.05); border-radius: 3px }
.markdown-body code::after, .markdown-body code::before { letter-spacing: -0.2em; content: ” ” }
.markdown-body pre>code { padding: 0; margin: 0; font-size: 100%; word-break: normal; white-space: pre; background: left top; border: 0 }
.markdown-body .highlight { margin-bottom: 16px }
.markdown-body .highlight pre { margin-bottom: 0; word-break: normal }
.markdown-body .highlight pre, .markdown-body pre { padding: 16px; overflow: auto; font-size: 85%; line-height: 1.45; background-color: rgba(246, 248, 250, 1); border-radius: 3px }
.markdown-body pre code { display: inline; padding: 0; margin: 0; overflow: visible; line-height: inherit; word-wrap: normal; background-color: rgba(0, 0, 0, 0); border: 0 }
.markdown-body pre code::after, .markdown-body pre code::before { content: normal }
.markdown-body .full-commit .btn-outline:not(:disabled):hover { color: rgba(0, 92, 197, 1); border-color: rgba(0, 92, 197, 1) }
.markdown-body kbd { display: inline-block; padding: 3px 5px; font: 11px / 10px SFMono-Regular, Consolas, “Liberation Mono”, Menlo, Courier, monospace; color: rgba(68, 77, 86, 1); vertical-align: middle; background-color: rgba(250, 251, 252, 1); border-top: 1px solid rgba(209, 213, 218, 1); border-right: 1px solid rgba(209, 213, 218, 1); border-bottom: 1px solid rgba(198, 203, 209, 1); border-left: 1px solid rgba(209, 213, 218, 1); border-radius: 3px; box-shadow: inset 0 -1px rgba(198, 203, 209, 1) }
.hljs, .katex .katex-html>.newline { display: block }
.node text, .noteText, div.mermaidTooltip { font-family: “trebuchet ms”, verdana, arial }
.markdown-body :checked+.radio-label { position: relative; z-index: 1; border-color: rgba(3, 102, 214, 1) }
.markdown-body .task-list-item+.task-list-item { margin-top: 3px }
.markdown-body .task-list-item input { margin: 0 0.2em 0.25em -1.6em; vertical-align: middle }
.markdown-body hr { border-bottom-color: rgba(238, 238, 238, 1) }
.hljs { overflow-x: auto; padding: 0.5em; color: rgba(51, 51, 51, 1); background: rgba(248, 248, 248, 1) }
.hljs-comment, .hljs-quote { color: rgba(153, 153, 136, 1); font-style: italic }
.hljs-keyword, .hljs-selector-tag, .hljs-subst { color: rgba(51, 51, 51, 1); font-weight: 700 }
.hljs-literal, .hljs-number, .hljs-tag .hljs-attr, .hljs-template-variable, .hljs-variable { color: rgba(0, 128, 128, 1) }
.hljs-doctag, .hljs-string { color: rgba(221, 17, 68, 1) }
.hljs-section, .hljs-selector-id, .hljs-title { color: rgba(153, 0, 0, 1); font-weight: 700 }
.hljs-subst { font-weight: 400 }
.hljs-class .hljs-title, .hljs-type { color: rgba(68, 85, 136, 1); font-weight: 700 }
.hljs-attribute, .hljs-name, .hljs-tag { color: rgba(0, 0, 128, 1); font-weight: 400 }
.hljs-meta, .hljs-strong { font-weight: 700 }
.hljs-link, .hljs-regexp { color: rgba(0, 153, 38, 1) }
.hljs-bullet, .hljs-symbol { color: rgba(153, 0, 115, 1) }
.hljs-built_in, .hljs-builtin-name { color: rgba(0, 134, 179, 1) }
.hljs-meta { color: rgba(153, 153, 153, 1) }
.hljs-deletion { background: rgba(255, 221, 221, 1) }
.hljs-addition { background: rgba(221, 255, 221, 1) }
.hljs-emphasis { font-style: italic }
.mermaid .label { color: rgba(51, 51, 51, 1) }
.node circle, .node ellipse, .node polygon, .node rect { fill: rgba(236, 236, 255, 1); stroke: rgba(204, 204, 255, 1); stroke-width: 1px }
.edgePath .path { stroke: rgba(51, 51, 51, 1) }
.edgeLabel { background-color: rgba(232, 232, 232, 1) }
.cluster rect { fill: rgba(255, 255, 222, 1) !important; rx: 4 !important; stroke: rgba(170, 170, 51, 1) !important; stroke-width: 1px !important }
.cluster text { fill: rgba(51, 51, 51, 1) }
.actor { stroke: rgba(204, 204, 255, 1); fill: rgba(236, 236, 255, 1) }
text.actor { fill: rgba(0, 0, 0, 1); stroke: none }
.actor-line { stroke: rgba(128, 128, 128, 1) }
.messageLine0, .messageLine1 { stroke-width: 1.5; stroke: rgba(51, 51, 51, 1) }
#arrowhead { fill: rgba(51, 51, 51, 1) }
#crosshead path { fill: rgba(51, 51, 51, 1) !important; stroke: rgba(51, 51, 51, 1) !important }
.messageText { fill: rgba(51, 51, 51, 1); stroke: none }
.labelBox { stroke: rgba(204, 204, 255, 1); fill: rgba(236, 236, 255, 1) }
.labelText, .loopText { fill: rgba(0, 0, 0, 1); stroke: none }
.loopLine { stroke-width: 2; stroke: rgba(204, 204, 255, 1) }
.note { stroke: rgba(170, 170, 51, 1); fill: rgba(255, 245, 173, 1) }
.noteText { fill: rgba(0, 0, 0, 1); stroke: none; font-size: 14px }
.section { stroke: none; opacity: 0.2 }
.section0 { fill: rgba(102, 102, 255, 0.49) }
.section2 { fill: rgba(255, 244, 0, 1) }
.section1, .section3 { fill: rgba(255, 255, 255, 1); opacity: 0.2 }
.sectionTitle0, .sectionTitle1, .sectionTitle2, .sectionTitle3 { fill: rgba(51, 51, 51, 1) }
.sectionTitle { text-anchor: start; font-size: 11px; text-height: 14px }
.grid .tick { stroke: rgba(211, 211, 211, 1); opacity: 0.3; shape-rendering: crispEdges }
.grid path { stroke-width: 0 }
.today { fill: none; stroke: rgba(255, 0, 0, 1); stroke-width: 2px }
.task { stroke-width: 2 }
.taskText { text-anchor: middle; font-size: 11px }
.taskTextOutsideRight { fill: rgba(0, 0, 0, 1); text-anchor: start; font-size: 11px }
.taskTextOutsideLeft { fill: rgba(0, 0, 0, 1); text-anchor: end; font-size: 11px }
.taskText0, .taskText1, .taskText2, .taskText3 { fill: rgba(255, 255, 255, 1) }
.task0, .task1, .task2, .task3 { fill: rgba(138, 144, 221, 1); stroke: rgba(83, 79, 188, 1) }
.taskTextOutside0, .taskTextOutside1, .taskTextOutside2, .taskTextOutside3 { fill: rgba(0, 0, 0, 1) }
.active0, .active1, .active2, .active3 { fill: rgba(191, 199, 255, 1); stroke: rgba(83, 79, 188, 1) }
.activeText0, .activeText1, .activeText2, .activeText3 { fill: rgba(0, 0, 0, 1) !important }
.done0, .done1, .done2, .done3 { stroke: rgba(128, 128, 128, 1); fill: rgba(211, 211, 211, 1); stroke-width: 2 }
.doneText0, .doneText1, .doneText2, .doneText3 { fill: rgba(0, 0, 0, 1) !important }
.crit0, .crit1, .crit2, .crit3 { stroke: rgba(255, 136, 136, 1); fill: rgba(255, 0, 0, 1); stroke-width: 2 }
.activeCrit0, .activeCrit1, .activeCrit2, .activeCrit3 { stroke: rgba(255, 136, 136, 1); fill: rgba(191, 199, 255, 1); stroke-width: 2 }
.doneCrit0, .doneCrit1, .doneCrit2, .doneCrit3 { stroke: rgba(255, 136, 136, 1); fill: rgba(211, 211, 211, 1); stroke-width: 2; cursor: pointer; shape-rendering: crispEdges }
.activeCritText0, .activeCritText1, .activeCritText2, .activeCritText3, .doneCritText0, .doneCritText1, .doneCritText2, .doneCritText3 { fill: rgba(0, 0, 0, 1) !important }
.titleText { text-anchor: middle; font-size: 18px; fill: rgba(0, 0, 0, 1) }
.node text { font-size: 14px }
div.mermaidTooltip { position: absolute; text-align: center; max-width: 200px; padding: 2px; font-size: 12px; background: rgba(255, 255, 222, 1); border: 1px solid rgba(170, 170, 51, 1); border-radius: 2px; pointer-events: none; z-index: 100 }
@font-face { font-family: KaTeX_AMS; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_AMS-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_AMS-Regular.woff”) format(“woff”), url(“fonts/KaTeX_AMS-Regular.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Caligraphic; font-style: normal; font-weight: 700; src: url(“fonts/KaTeX_Caligraphic-Bold.woff2”) format(“woff2”), url(“fonts/KaTeX_Caligraphic-Bold.woff”) format(“woff”), url(“fonts/KaTeX_Caligraphic-Bold.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Caligraphic; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_Caligraphic-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_Caligraphic-Regular.woff”) format(“woff”), url(“fonts/KaTeX_Caligraphic-Regular.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Fraktur; font-style: normal; font-weight: 700; src: url(“fonts/KaTeX_Fraktur-Bold.woff2”) format(“woff2”), url(“fonts/KaTeX_Fraktur-Bold.woff”) format(“woff”), url(“fonts/KaTeX_Fraktur-Bold.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Fraktur; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_Fraktur-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_Fraktur-Regular.woff”) format(“woff”), url(“fonts/KaTeX_Fraktur-Regular.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Main; font-style: normal; font-weight: 700; src: url(“fonts/KaTeX_Main-Bold.woff2”) format(“woff2”), url(“fonts/KaTeX_Main-Bold.woff”) format(“woff”), url(“fonts/KaTeX_Main-Bold.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Main; font-style: italic; font-weight: 700; src: url(“fonts/KaTeX_Main-BoldItalic.woff2”) format(“woff2”), url(“fonts/KaTeX_Main-BoldItalic.woff”) format(“woff”), url(“fonts/KaTeX_Main-BoldItalic.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Main; font-style: italic; font-weight: 400; src: url(“fonts/KaTeX_Main-Italic.woff2”) format(“woff2”), url(“fonts/KaTeX_Main-Italic.woff”) format(“woff”), url(“fonts/KaTeX_Main-Italic.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Main; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_Main-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_Main-Regular.woff”) format(“woff”), url(“fonts/KaTeX_Main-Regular.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Math; font-style: italic; font-weight: 700; src: url(“fonts/KaTeX_Math-BoldItalic.woff2”) format(“woff2”), url(“fonts/KaTeX_Math-BoldItalic.woff”) format(“woff”), url(“fonts/KaTeX_Math-BoldItalic.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Math; font-style: italic; font-weight: 400; src: url(“fonts/KaTeX_Math-Italic.woff2”) format(“woff2”), url(“fonts/KaTeX_Math-Italic.woff”) format(“woff”), url(“fonts/KaTeX_Math-Italic.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_SansSerif; font-style: normal; font-weight: 700; src: url(“fonts/KaTeX_SansSerif-Bold.woff2”) format(“woff2”), url(“fonts/KaTeX_SansSerif-Bold.woff”) format(“woff”), url(“fonts/KaTeX_SansSerif-Bold.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_SansSerif; font-style: italic; font-weight: 400; src: url(“fonts/KaTeX_SansSerif-Italic.woff2”) format(“woff2”), url(“fonts/KaTeX_SansSerif-Italic.woff”) format(“woff”), url(“fonts/KaTeX_SansSerif-Italic.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_SansSerif; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_SansSerif-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_SansSerif-Regular.woff”) format(“woff”), url(“fonts/KaTeX_SansSerif-Regular.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Script; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_Script-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_Script-Regular.woff”) format(“woff”), url(“fonts/KaTeX_Script-Regular.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Size1; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_Size1-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_Size1-Regular.woff”) format(“woff”), url(“fonts/KaTeX_Size1-Regular.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Size2; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_Size2-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_Size2-Regular.woff”) format(“woff”), url(“fonts/KaTeX_Size2-Regular.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Size3; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_Size3-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_Size3-Regular.woff”) format(“woff”), url(“fonts/KaTeX_Size3-Regular.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Size4; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_Size4-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_Size4-Regular.woff”) format(“woff”), url(“fonts/KaTeX_Size4-Regular.ttf”) format(“truetype”) }
@font-face { font-family: KaTeX_Typewriter; font-style: normal; font-weight: 400; src: url(“fonts/KaTeX_Typewriter-Regular.woff2”) format(“woff2”), url(“fonts/KaTeX_Typewriter-Regular.woff”) format(“woff”), url(“fonts/KaTeX_Typewriter-Regular.ttf”) format(“truetype”) }
.katex { font: 400 1.21em / 1.2 KaTeX_Main, Times New Roman, serif; text-indent: 0; text-rendering: auto }
.katex .mathit, .katex .textit { font-style: italic }
.katex * { -ms-high-contrast-adjust: none !important }
.katex .katex-mathml { border: 0; clip: rect(1px, 1px, 1px, 1px); height: 1px; overflow: hidden; padding: 0; position: absolute; width: 1px }
.katex .base { position: relative; white-space: nowrap; width: min-content }
.katex .base, .katex .strut { display: inline-block }
.katex .textbf { font-weight: 700 }
.katex .textrm { font-family: KaTeX_Main }
.katex .textsf { font-family: KaTeX_SansSerif }
.katex .texttt { font-family: KaTeX_Typewriter }
.katex .mathdefault { font-family: KaTeX_Math; font-style: italic }
.katex .mathit { font-family: KaTeX_Main }
.katex .mathrm { font-style: normal }
.katex .mathbf { font-family: KaTeX_Main; font-weight: 700 }
.katex .boldsymbol { font-family: KaTeX_Math; font-style: italic; font-weight: 700 }
.katex .amsrm, .katex .mathbb, .katex .textbb { font-family: KaTeX_AMS }
.katex .mathcal { font-family: KaTeX_Caligraphic }
.katex .mathfrak, .katex .textfrak { font-family: KaTeX_Fraktur }
.katex .mathtt { font-family: KaTeX_Typewriter }
.katex .mathscr, .katex .textscr { font-family: KaTeX_Script }
.katex .mathsf, .katex .textsf { font-family: KaTeX_SansSerif }
.katex .mathboldsf, .katex .textboldsf { font-family: KaTeX_SansSerif; font-weight: 700 }
.katex .mathitsf, .katex .textitsf { font-family: KaTeX_SansSerif; font-style: italic }
.katex .mainrm { font-family: KaTeX_Main; font-style: normal }
.katex .vlist-t { display: inline-table; table-layout: fixed }
.katex .vlist-r { display: table-row }
.katex .vlist { display: table-cell; position: relative; vertical-align: bottom }
.katex .vlist>span { display: block; height: 0; position: relative }
.katex .vlist>span>span { display: inline-block }
.katex .vlist>span>.pstrut { overflow: hidden; width: 0 }
.katex .vlist-t2 { margin-right: -2px }
.katex .vlist-s { display: table-cell; font-size: 1px; min-width: 2px; vertical-align: bottom; width: 2px }
.katex .clap>.fix, .katex .fontsize-ensurer, .katex .hdashline, .katex .llap>.fix, .katex .mfrac .frac-line, .katex .mspace, .katex .nulldelimiter, .katex .rlap>.fix, .katex .rule, .katex .sizing { display: inline-block }
.katex .msupsub { text-align: left }
.katex .accent>.vlist-t, .katex .mfrac>span>span, .katex .mtable .col-align-c>.vlist-t, .katex .op-limits>.vlist-t { text-align: center }
.katex .mfrac .frac-line { border-bottom-style: solid; width: 100% }
.katex .hdashline, .katex .hline, .katex .mfrac .frac-line, .katex .overline .overline-line, .katex .rule, .katex .underline .underline-line { min-height: 1px }
.katex .clap, .katex .llap, .katex .rlap { position: relative; width: 0 }
.katex .clap>.inner, .katex .llap>.inner, .katex .rlap>.inner { position: absolute }
.katex .accent .accent-body, .katex .delimcenter, .katex .op-symbol, .katex .rule { position: relative }
.katex .llap>.inner { right: 0 }
.katex .clap>.inner, .katex .rlap>.inner { left: 0 }
.katex .clap>.inner>span { margin-left: -50%; margin-right: 50% }
.katex .rule { border: 0 solid }
.katex .hline, .katex .overline .overline-line, .katex .underline .underline-line { border-bottom-style: solid; display: inline-block; width: 100% }
.katex .hdashline { border-bottom-style: dashed; width: 100% }
.katex .sqrt>.root { margin-left: 0.27777778em; margin-right: -0.55555556em }
.katex .fontsize-ensurer.reset-size1.size1, .katex .sizing.reset-size1.size1 { font-size: 1em }
.katex .fontsize-ensurer.reset-size1.size2, .katex .sizing.reset-size1.size2 { font-size: 1.2em }
.katex .fontsize-ensurer.reset-size1.size3, .katex .sizing.reset-size1.size3 { font-size: 1.4em }
.katex .fontsize-ensurer.reset-size1.size4, .katex .sizing.reset-size1.size4 { font-size: 1.6em }
.katex .fontsize-ensurer.reset-size1.size5, .katex .sizing.reset-size1.size5 { font-size: 1.8em }
.katex .fontsize-ensurer.reset-size1.size6, .katex .sizing.reset-size1.size6 { font-size: 2em }
.katex .fontsize-ensurer.reset-size1.size7, .katex .sizing.reset-size1.size7 { font-size: 2.4em }
.katex .fontsize-ensurer.reset-size1.size8, .katex .sizing.reset-size1.size8 { font-size: 2.88em }
.katex .fontsize-ensurer.reset-size1.size9, .katex .sizing.reset-size1.size9 { font-size: 3.456em }
.katex .fontsize-ensurer.reset-size1.size10, .katex .sizing.reset-size1.size10 { font-size: 4.148em }
.katex .fontsize-ensurer.reset-size1.size11, .katex .sizing.reset-size1.size11 { font-size: 4.976em }
.katex .fontsize-ensurer.reset-size2.size1, .katex .sizing.reset-size2.size1 { font-size: 0.83333333em }
.katex .fontsize-ensurer.reset-size2.size2, .katex .sizing.reset-size2.size2 { font-size: 1em }
.katex .fontsize-ensurer.reset-size2.size3, .katex .sizing.reset-size2.size3 { font-size: 1.16666667em }
.katex .fontsize-ensurer.reset-size2.size4, .katex .sizing.reset-size2.size4 { font-size: 1.33333333em }
.katex .fontsize-ensurer.reset-size2.size5, .katex .sizing.reset-size2.size5 { font-size: 1.5em }
.katex .fontsize-ensurer.reset-size2.size6, .katex .sizing.reset-size2.size6 { font-size: 1.66666667em }
.katex .fontsize-ensurer.reset-size2.size7, .katex .sizing.reset-size2.size7 { font-size: 2em }
.katex .fontsize-ensurer.reset-size2.size8, .katex .sizing.reset-size2.size8 { font-size: 2.4em }
.katex .fontsize-ensurer.reset-size2.size9, .katex .sizing.reset-size2.size9 { font-size: 2.88em }
.katex .fontsize-ensurer.reset-size2.size10, .katex .sizing.reset-size2.size10 { font-size: 3.45666667em }
.katex .fontsize-ensurer.reset-size2.size11, .katex .sizing.reset-size2.size11 { font-size: 4.14666667em }
.katex .fontsize-ensurer.reset-size3.size1, .katex .sizing.reset-size3.size1 { font-size: 0.71428571em }
.katex .fontsize-ensurer.reset-size3.size2, .katex .sizing.reset-size3.size2 { font-size: 0.85714286em }
.katex .fontsize-ensurer.reset-size3.size3, .katex .sizing.reset-size3.size3 { font-size: 1em }
.katex .fontsize-ensurer.reset-size3.size4, .katex .sizing.reset-size3.size4 { font-size: 1.14285714em }
.katex .fontsize-ensurer.reset-size3.size5, .katex .sizing.reset-size3.size5 { font-size: 1.28571429em }
.katex .fontsize-ensurer.reset-size3.size6, .katex .sizing.reset-size3.size6 { font-size: 1.42857143em }
.katex .fontsize-ensurer.reset-size3.size7, .katex .sizing.reset-size3.size7 { font-size: 1.71428571em }
.katex .fontsize-ensurer.reset-size3.size8, .katex .sizing.reset-size3.size8 { font-size: 2.05714286em }
.katex .fontsize-ensurer.reset-size3.size9, .katex .sizing.reset-size3.size9 { font-size: 2.46857143em }
.katex .fontsize-ensurer.reset-size3.size10, .katex .sizing.reset-size3.size10 { font-size: 2.96285714em }
.katex .fontsize-ensurer.reset-size3.size11, .katex .sizing.reset-size3.size11 { font-size: 3.55428571em }
.katex .fontsize-ensurer.reset-size4.size1, .katex .sizing.reset-size4.size1 { font-size: 0.625em }
.katex .fontsize-ensurer.reset-size4.size2, .katex .sizing.reset-size4.size2 { font-size: 0.75em }
.katex .fontsize-ensurer.reset-size4.size3, .katex .sizing.reset-size4.size3 { font-size: 0.875em }
.katex .fontsize-ensurer.reset-size4.size4, .katex .sizing.reset-size4.size4 { font-size: 1em }
.katex .fontsize-ensurer.reset-size4.size5, .katex .sizing.reset-size4.size5 { font-size: 1.125em }
.katex .fontsize-ensurer.reset-size4.size6, .katex .sizing.reset-size4.size6 { font-size: 1.25em }
.katex .fontsize-ensurer.reset-size4.size7, .katex .sizing.reset-size4.size7 { font-size: 1.5em }
.katex .fontsize-ensurer.reset-size4.size8, .katex .sizing.reset-size4.size8 { font-size: 1.8em }
.katex .fontsize-ensurer.reset-size4.size9, .katex .sizing.reset-size4.size9 { font-size: 2.16em }
.katex .fontsize-ensurer.reset-size4.size10, .katex .sizing.reset-size4.size10 { font-size: 2.5925em }
.katex .fontsize-ensurer.reset-size4.size11, .katex .sizing.reset-size4.size11 { font-size: 3.11em }
.katex .fontsize-ensurer.reset-size5.size1, .katex .sizing.reset-size5.size1 { font-size: 0.55555556em }
.katex .fontsize-ensurer.reset-size5.size2, .katex .sizing.reset-size5.size2 { font-size: 0.66666667em }
.katex .fontsize-ensurer.reset-size5.size3, .katex .sizing.reset-size5.size3 { font-size: 0.77777778em }
.katex .fontsize-ensurer.reset-size5.size4, .katex .sizing.reset-size5.size4 { font-size: 0.88888889em }
.katex .fontsize-ensurer.reset-size5.size5, .katex .sizing.reset-size5.size5 { font-size: 1em }
.katex .fontsize-ensurer.reset-size5.size6, .katex .sizing.reset-size5.size6 { font-size: 1.11111111em }
.katex .fontsize-ensurer.reset-size5.size7, .katex .sizing.reset-size5.size7 { font-size: 1.33333333em }
.katex .fontsize-ensurer.reset-size5.size8, .katex .sizing.reset-size5.size8 { font-size: 1.6em }
.katex .fontsize-ensurer.reset-size5.size9, .katex .sizing.reset-size5.size9 { font-size: 1.92em }
.katex .fontsize-ensurer.reset-size5.size10, .katex .sizing.reset-size5.size10 { font-size: 2.30444444em }
.katex .fontsize-ensurer.reset-size5.size11, .katex .sizing.reset-size5.size11 { font-size: 2.76444444em }
.katex .fontsize-ensurer.reset-size6.size1, .katex .sizing.reset-size6.size1 { font-size: 0.5em }
.katex .fontsize-ensurer.reset-size6.size2, .katex .sizing.reset-size6.size2 { font-size: 0.6em }
.katex .fontsize-ensurer.reset-size6.size3, .katex .sizing.reset-size6.size3 { font-size: 0.7em }
.katex .fontsize-ensurer.reset-size6.size4, .katex .sizing.reset-size6.size4 { font-size: 0.8em }
.katex .fontsize-ensurer.reset-size6.size5, .katex .sizing.reset-size6.size5 { font-size: 0.9em }
.katex .fontsize-ensurer.reset-size6.size6, .katex .sizing.reset-size6.size6 { font-size: 1em }
.katex .fontsize-ensurer.reset-size6.size7, .katex .sizing.reset-size6.size7 { font-size: 1.2em }
.katex .fontsize-ensurer.reset-size6.size8, .katex .sizing.reset-size6.size8 { font-size: 1.44em }
.katex .fontsize-ensurer.reset-size6.size9, .katex .sizing.reset-size6.size9 { font-size: 1.728em }
.katex .fontsize-ensurer.reset-size6.size10, .katex .sizing.reset-size6.size10 { font-size: 2.074em }
.katex .fontsize-ensurer.reset-size6.size11, .katex .sizing.reset-size6.size11 { font-size: 2.488em }
.katex .fontsize-ensurer.reset-size7.size1, .katex .sizing.reset-size7.size1 { font-size: 0.41666667em }
.katex .fontsize-ensurer.reset-size7.size2, .katex .sizing.reset-size7.size2 { font-size: 0.5em }
.katex .fontsize-ensurer.reset-size7.size3, .katex .sizing.reset-size7.size3 { font-size: 0.58333333em }
.katex .fontsize-ensurer.reset-size7.size4, .katex .sizing.reset-size7.size4 { font-size: 0.66666667em }
.katex .fontsize-ensurer.reset-size7.size5, .katex .sizing.reset-size7.size5 { font-size: 0.75em }
.katex .fontsize-ensurer.reset-size7.size6, .katex .sizing.reset-size7.size6 { font-size: 0.83333333em }
.katex .fontsize-ensurer.reset-size7.size7, .katex .sizing.reset-size7.size7 { font-size: 1em }
.katex .fontsize-ensurer.reset-size7.size8, .katex .sizing.reset-size7.size8 { font-size: 1.2em }
.katex .fontsize-ensurer.reset-size7.size9, .katex .sizing.reset-size7.size9 { font-size: 1.44em }
.katex .fontsize-ensurer.reset-size7.size10, .katex .sizing.reset-size7.size10 { font-size: 1.72833333em }
.katex .fontsize-ensurer.reset-size7.size11, .katex .sizing.reset-size7.size11 { font-size: 2.07333333em }
.katex .fontsize-ensurer.reset-size8.size1, .katex .sizing.reset-size8.size1 { font-size: 0.34722222em }
.katex .fontsize-ensurer.reset-size8.size2, .katex .sizing.reset-size8.size2 { font-size: 0.41666667em }
.katex .fontsize-ensurer.reset-size8.size3, .katex .sizing.reset-size8.size3 { font-size: 0.48611111em }
.katex .fontsize-ensurer.reset-size8.size4, .katex .sizing.reset-size8.size4 { font-size: 0.55555556em }
.katex .fontsize-ensurer.reset-size8.size5, .katex .sizing.reset-size8.size5 { font-size: 0.625em }
.katex .fontsize-ensurer.reset-size8.size6, .katex .sizing.reset-size8.size6 { font-size: 0.69444444em }
.katex .fontsize-ensurer.reset-size8.size7, .katex .sizing.reset-size8.size7 { font-size: 0.83333333em }
.katex .fontsize-ensurer.reset-size8.size8, .katex .sizing.reset-size8.size8 { font-size: 1em }
.katex .fontsize-ensurer.reset-size8.size9, .katex .sizing.reset-size8.size9 { font-size: 1.2em }
.katex .fontsize-ensurer.reset-size8.size10, .katex .sizing.reset-size8.size10 { font-size: 1.44027778em }
.katex .fontsize-ensurer.reset-size8.size11, .katex .sizing.reset-size8.size11 { font-size: 1.72777778em }
.katex .fontsize-ensurer.reset-size9.size1, .katex .sizing.reset-size9.size1 { font-size: 0.28935185em }
.katex .fontsize-ensurer.reset-size9.size2, .katex .sizing.reset-size9.size2 { font-size: 0.34722222em }
.katex .fontsize-ensurer.reset-size9.size3, .katex .sizing.reset-size9.size3 { font-size: 0.40509259em }
.katex .fontsize-ensurer.reset-size9.size4, .katex .sizing.reset-size9.size4 { font-size: 0.46296296em }
.katex .fontsize-ensurer.reset-size9.size5, .katex .sizing.reset-size9.size5 { font-size: 0.52083333em }
.katex .fontsize-ensurer.reset-size9.size6, .katex .sizing.reset-size9.size6 { font-size: 0.5787037em }
.katex .fontsize-ensurer.reset-size9.size7, .katex .sizing.reset-size9.size7 { font-size: 0.69444444em }
.katex .fontsize-ensurer.reset-size9.size8, .katex .sizing.reset-size9.size8 { font-size: 0.83333333em }
.katex .fontsize-ensurer.reset-size9.size9, .katex .sizing.reset-size9.size9 { font-size: 1em }
.katex .fontsize-ensurer.reset-size9.size10, .katex .sizing.reset-size9.size10 { font-size: 1.20023148em }
.katex .fontsize-ensurer.reset-size9.size11, .katex .sizing.reset-size9.size11 { font-size: 1.43981481em }
.katex .fontsize-ensurer.reset-size10.size1, .katex .sizing.reset-size10.size1 { font-size: 0.24108004em }
.katex .fontsize-ensurer.reset-size10.size2, .katex .sizing.reset-size10.size2 { font-size: 0.28929605em }
.katex .fontsize-ensurer.reset-size10.size3, .katex .sizing.reset-size10.size3 { font-size: 0.33751205em }
.katex .fontsize-ensurer.reset-size10.size4, .katex .sizing.reset-size10.size4 { font-size: 0.38572806em }
.katex .fontsize-ensurer.reset-size10.size5, .katex .sizing.reset-size10.size5 { font-size: 0.43394407em }
.katex .fontsize-ensurer.reset-size10.size6, .katex .sizing.reset-size10.size6 { font-size: 0.48216008em }
.katex .fontsize-ensurer.reset-size10.size7, .katex .sizing.reset-size10.size7 { font-size: 0.57859209em }
.katex .fontsize-ensurer.reset-size10.size8, .katex .sizing.reset-size10.size8 { font-size: 0.69431051em }
.katex .fontsize-ensurer.reset-size10.size9, .katex .sizing.reset-size10.size9 { font-size: 0.83317261em }
.katex .fontsize-ensurer.reset-size10.size10, .katex .sizing.reset-size10.size10 { font-size: 1em }
.katex .fontsize-ensurer.reset-size10.size11, .katex .sizing.reset-size10.size11 { font-size: 1.19961427em }
.katex .fontsize-ensurer.reset-size11.size1, .katex .sizing.reset-size11.size1 { font-size: 0.20096463em }
.katex .fontsize-ensurer.reset-size11.size2, .katex .sizing.reset-size11.size2 { font-size: 0.24115756em }
.katex .fontsize-ensurer.reset-size11.size3, .katex .sizing.reset-size11.size3 { font-size: 0.28135048em }
.katex .fontsize-ensurer.reset-size11.size4, .katex .sizing.reset-size11.size4 { font-size: 0.32154341em }
.katex .fontsize-ensurer.reset-size11.size5, .katex .sizing.reset-size11.size5 { font-size: 0.36173633em }
.katex .fontsize-ensurer.reset-size11.size6, .katex .sizing.reset-size11.size6 { font-size: 0.40192926em }
.katex .fontsize-ensurer.reset-size11.size7, .katex .sizing.reset-size11.size7 { font-size: 0.48231511em }
.katex .fontsize-ensurer.reset-size11.size8, .katex .sizing.reset-size11.size8 { font-size: 0.57877814em }
.katex .fontsize-ensurer.reset-size11.size9, .katex .sizing.reset-size11.size9 { font-size: 0.69453376em }
.katex .fontsize-ensurer.reset-size11.size10, .katex .sizing.reset-size11.size10 { font-size: 0.83360129em }
.katex .fontsize-ensurer.reset-size11.size11, .katex .sizing.reset-size11.size11 { font-size: 1em }
.katex .delimsizing.size1 { font-family: KaTeX_Size1 }
.katex .delimsizing.size2 { font-family: KaTeX_Size2 }
.katex .delimsizing.size3 { font-family: KaTeX_Size3 }
.katex .delimsizing.size4 { font-family: KaTeX_Size4 }
.katex .delimsizing.mult .delim-size1>span { font-family: KaTeX_Size1 }
.katex .delimsizing.mult .delim-size4>span { font-family: KaTeX_Size4 }
.katex .nulldelimiter { width: 0.12em }
.katex .op-symbol.small-op { font-family: KaTeX_Size1 }
.katex .op-symbol.large-op { font-family: KaTeX_Size2 }
.katex .accent .accent-body:not(.accent-full) { width: 0 }
.katex .overlay { display: block }
.katex .mtable .vertical-separator { border-right: 0.05em solid; display: inline-block; margin: 0 -0.025em; min-width: 1px }
.katex .mtable .vs-dashed { border-right: 0.05em dashed }
.katex .mtable .arraycolsep { display: inline-block }
.katex .mtable .col-align-l>.vlist-t { text-align: left }
.katex .mtable .col-align-r>.vlist-t { text-align: right }
.katex .svg-align { text-align: left }
.katex .mover, .katex .munder, .katex .x-arrow, .katex-display, div[data-role=”mermaid”] { text-align: center }
.katex svg { display: block; fill: currentColor; fill-opacity: 1; fill-rule: nonzero; height: inherit; position: absolute; stroke: currentColor; stroke-dasharray: none; stroke-dashoffset: 0; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; stroke-opacity: 1; stroke-width: 1; width: 100% }
.katex .hide-tail, .katex .stretchy { overflow: hidden; position: relative; width: 100% }
.katex svg path { stroke: none }
.katex .stretchy { display: block }
.katex .stretchy:after, .katex .stretchy:before { content: “” }
.katex .brace-center, .katex .brace-left, .katex .brace-right, .katex .halfarrow-left, .katex .halfarrow-right { position: absolute; overflow: hidden }
.katex .halfarrow-left { left: 0; width: 50.2% }
.katex .halfarrow-right { right: 0; width: 50.2% }
.katex .brace-left { left: 0; width: 25.1% }
.katex .brace-center { left: 25%; width: 50% }
.katex .brace-right { right: 0; width: 25.1% }
.katex .x-arrow-pad { padding: 0 0.5em }
.katex .boxpad { padding: 0 0.3em }
.katex .fbox { border: 0.04em solid rgba(0, 0, 0, 1); box-sizing: border-box }
.katex .fcolorbox { border: 0.04em solid; box-sizing: border-box }
.katex .cancel-pad { padding: 0 0.2em }
.katex .cancel-lap { margin-left: -0.2em; margin-right: -0.2em }
.katex .sout { border-bottom-style: solid; border-bottom-width: 0.08em }
.katex-display { display: block; margin: 1em 0 }
.katex-display>.katex { display: block; text-align: center; white-space: nowrap }
.katex-display>.katex>.katex-html { display: block; position: relative }
.katex-display>.katex>.katex-html>.tag { position: absolute; right: 0 }
body { margin: 0; padding: 0 }
.markdown-body { min-width: 256px; max-width: 978px; margin: 0 auto; padding: 20px; font-size: 14px }
.markdown-body h1 { font-size: 2.25em }
.markdown-body h2 { font-size: 1.75em }
.markdown-body h3 { font-size: 1.5em }
.markdown-body h4 { font-size: 1.25em }
.markdown-body h5, .markdown-body h6 { font-size: 1em }
div[data-role=”mermaid”] svg { height: auto }
hr.footnotes-sep { margin: 64px 0 32px; height: 1px }
.footnotes { font-size: 90%; padding-left: 16px }
li.footnote-item>p { margin: 8px 0 }
.danger, .info, .success, .warning { padding: 15px; margin-bottom: 20px; border: 1px solid rgba(0, 0, 0, 0); border-radius: 4px }
.danger>p:last-child, .info>p:last-child, .success>p:last-child, .warning>p:last-child { margin-bottom: 0 }
.success { color: rgba(60, 118, 61, 1); background-color: rgba(223, 240, 216, 1); border-color: rgba(214, 233, 198, 1) }
.info { color: rgba(49, 112, 143, 1); background-color: rgba(217, 237, 247, 1); border-color: rgba(188, 232, 241, 1) }
.warning { color: rgba(138, 109, 59, 1); background-color: rgba(252, 248, 227, 1); border-color: rgba(250, 235, 204, 1) }
.danger { color: rgba(169, 68, 66, 1); background-color: rgba(242, 222, 222, 1); border-color: rgba(235, 204, 209, 1) }
abbr[title] { cursor: help; border-bottom: 1px dotted rgba(119, 119, 119, 1) }
ul.table-of-contents li { margin: 4px 0 }
.markdown-body table { border-spacing: 0; border-collapse: collapse; width: auto; display: inline-block; overflow: hidden }
.markdown-body table td, .markdown-body table th { word-break: break-all }
Java集合详解
一、数组和集合的比较
数组不是面向对象的,存在明显的缺陷,集合弥补了数组的缺点,比数组更灵活更实用,而且不同的集合框架类可适用不同场合。如下:
- 数组能存放基本数据类型和对象,而集合类存放的都是对象,集合类不能存放基本数据类型。数组和集合存放的对象皆为对象的引用地址。
- 数组容易固定无法动态改变,集合类容量动态改变。
- 数组无法判断其中实际存有多少元素,length只告诉了数组的容量,而集合的size()可以确切知道元素的个数
- 集合有多种实现方式和不同适用场合,不像数组仅采用顺序表方式
- 集合以类的形式存在,具有封装、继承、多态等类的特性,通过简单的方法和属性即可实现各种复杂操作,大大提高了软件的开发效率
二、Java集合
Collection和Map,是集合框架的根接口。
Collection的子接口:
Set:接口 —实现类: HashSet、LinkedHashSet
Set的子接口SortedSet接口—实现类:TreeSet
List:接口—实现类: LinkedList,Vector,ArrayList
List集合
有序列表,允许存放重复的元素;
实现类:
- ArrayList:数组实现,查询快,增删慢,轻量级;(线程不安全)
- LinkedList:双向链表实现,增删快,查询慢 (线程不安全)
- Vector:数组实现,重量级 (线程安全、使用少)
ArrayList
底层是Object数组,所以ArrayList具有数组的查询速度快的优点以及增删速度慢的缺点。
而在LinkedList的底层是一种双向循环链表。在此链表上每一个数据节点都由三部分组成:前指针(指向前面的节点的位置),数据,后指针(指向后面的节点的位置)。最后一个节点的后指针指向第一个节点的前指针,形成一个循环。
双向循环链表的查询效率低但是增删效率高。
ArrayList和LinkedList在用法上没有区别,但是在功能上还是有区别的。
ArrayList自动扩充机制
实现机制:ArrayList.ensureCapacity(int minCapacity)
首先得到当前elementData 属性的长度oldCapacity。
然后通过判断oldCapacity和minCapacity参数谁大来决定是否需要扩容, 如果minCapacity大于
oldCapacity,那么我们就对当前的List对象进行扩容。
扩容的的策略为:取(oldCapacity * 3)/2 + 1和minCapacity之间更大的那个。然后使用数组拷
贝的方法,把以前存放的数据转移到新的数组对象中
如果minCapacity不大于oldCapacity那么就不进行扩容。
LinkedList
LinkedList是采用双向循环链表实现的。
利用LinkedList实现栈(stack)、队列(queue)、双向队列(double-ended queue )。
它具有方法addFirst()、addLast()、getFirst()、getLast()、removeFirst()、removeLast()等。
经常用在增删操作较多而查询操作很少的情况下:
队列和堆栈。
队列:先进先出的数据结构。
栈:后进先出的数据结构。
注意:使用栈的时候一定不能提供方法让不是最后一个元素的元素获得出栈的机会。
用LinkedList实现队列:
队列(Queue)是限定所有的插入只能在表的一端进行,而所有的删除都在表的另一端进行的线性表。
表中允许插入的一端称为队尾(Rear),允许删除的一端称为队头(Front)。
队列的操作是按先进先出(FIFO)的原则进行的。
队列的物理存储可以用顺序存储结构,也可以用链式存储结构。
用LinkedList实现栈:
栈(Stack)也是一种特殊的线性表,是一种后进先出(LIFO)的结构。
栈是限定仅在表尾进行插入和删除运算的线性表,表尾称为栈顶(top),表头称为栈底(bottom)。
栈的物理存储可以用顺序存储结构,也可以用链式存储结构。
Vector
(与ArrayList相似,区别是Vector是重量级的组件,使用使消耗的资源比较多。)
结论:在考虑并发的情况下用Vector(保证线程的安全)。
在不考虑并发的情况下用ArrayList(不能保证线程的安全)。
List常用方法:
void add(int index, Object element) :添加对象element到位置index上
boolean addAll(int index, Collection collection) :在index位置后添加容器collection中所有的元素
Object get(int index) :取出下标为index的位置的元素
int indexOf(Object element) :查找对象element 在List中第一次出现的位置
int lastIndexOf(Object element) :查找对象element 在List中最后出现的位置
Object remove(int index) :删除index位置上的元素
ListIterator listIterator(int startIndex) :返回一个ListIterator 跌代器,开始位置为startIndex
List subList(int fromIndex, int toIndex) :返回一个子列表List ,元素存放为从 fromIndex 到toIndex之前的一个元素
Set集合
扩展Collection接口
无序集合,不允许存放重复的元素;允许使用null元素
对 add()、equals() 和 hashCode() 方法添加了限制
HashSet和TreeSet是Set的实现
rect { }
#mermaidChart0 .node text { fill: rgba(0, 0, 0, 1); stroke: none; font-weight: 300; font-family: “Helvetica Neue”, Helvetica, Arial, sans-serf; font-size: 14px }
#mermaidChart0 .edgeLabel text { fill: rgba(0, 0, 0, 1); stroke: none; font-weight: 300; font-family: “Helvetica Neue”, Helvetica, Arial, sans-serf; font-size: 14px }
#mermaidChart0 .cluster rect { rx: 4px; fill: rgba(255, 255, 222, 1); stroke: rgba(170, 170, 51, 1); stroke-width: 1px }
.markdown-body * { box-sizing: border-box }
.node rect, .node circle, .node ellipse, .node polygon { fill: rgba(236, 236, 255, 1); stroke: rgba(204, 204, 255, 1); stroke-width: 1px }
.edgePath .path { stroke: rgba(51, 51, 51, 1) }
.edgeLabel { background-color: rgba(232, 232, 232, 1) }
rect { }
#mermaidChart1 .node text { fill: rgba(0, 0, 0, 1); stroke: none; font-weight: 300; font-family: “Helvetica Neue”, Helvetica, Arial, sans-serf; font-size: 14px }
#mermaidChart1 .edgeLabel text { fill: rgba(0, 0, 0, 1); stroke: none; font-weight: 300; font-family: “Helvetica Neue”, Helvetica, Arial, sans-serf; font-size: 14px }
#mermaidChart1 .cluster rect { rx: 4px; fill: rgba(255, 255, 222, 1); stroke: rgba(170, 170, 51, 1); stroke-width: 1px }
.markdown-body * { box-sizing: border-box }
.node rect, .node circle, .node ellipse, .node polygon { fill: rgba(236, 236, 255, 1); stroke: rgba(204, 204, 255, 1); stroke-width: 1px }
.edgePath .path { stroke: rgba(51, 51, 51, 1) }
.edgeLabel { background-color: rgba(232, 232, 232, 1) }
HashSet 的后台有一个HashMap;初始化后台容量;只不过生成一个HashSet的话,系统只提供key的访问; 如果有两个Key重复,那么会覆盖之前的;
实现类 :
HashSet:equals返回true,hashCode返回相同的整数;哈希表;存储的数据是无序的。
LinkedHashSet:此实现与HashSet的不同之外在于,后者维护着一个运行于所有条目的双重链接列表。存储的数据是有序的。
HashSet类
HashSet类直接实现了Set接口,其底层其实是包装了一个HashMap去实现的。HashSet采用HashCode算法来存取集合中的元素,因此具有比较好的读取和查找性能。
HashSet的特征:
- 不仅不能保证元素插入的顺序,而且在元素在以后的顺序中也可能变化(这是由HashSet按HashCode存储对象(元素)决定的,对象变化则可能导致HashCode变化)
- HashSet是线程非安全的
- HashSet元素值可以为NULL
HashSet常用方法:
- public boolean contains(Object o) :如果set包含指定元素,返回true
- public Iterator iterator()返回set中元素的迭代器
- public Object[] toArray() :返回包含set中所有元素的数组public Object[] toArray(Object[] a) :返回包含set中所有元素的数组,返回数组的运行时类型是指定数组的运行时类型
- public boolean add(Object o) :如果set中不存在指定元素,则向set加入
- public boolean remove(Object o) :如果set中存在指定元素,则从set中删除
- public boolean removeAll(Collection c) :如果set包含指定集合,则从set中删除指定集合的所有元素
- public boolean containsAll(Collection c) :如果set包含指定集合的所有元素,返回true。如果指定集合也是一个set,只有是当前set的子集时,方法返回true
实现Set接口的HashSet,依靠HashMap来实现的。
我们应该为要存放到散列表的各个对象定义hashCode()和equals()。
HashSet的equals和HashCode:
前面说过,Set集合是不允许重复元素的,否则将会引发各种奇怪的问题。那么HashSet如何判断元素重复呢?
HashSet需要同时通过equals和HashCode来判断两个元素是否相等,具体规则是,如果两个元素通过equals为true,并且两个元素的hashCode相等,则这两个元素相等(即重复)。
所以如果要重写保存在HashSet中的对象的equals方法,也要重写hashCode方法,重写前后hashCode返回的结果相等(即保证保存在同一个位置)。所有参与计算 hashCode() 返回值的关键属性,都应该用于作为 equals() 比较的标准。
试想如果重写了equals方法但不重写hashCode方法,即相同equals结果的两个对象将会被HashSet当作两个元素保存起来,这与我们设计HashSet的初衷不符(元素不重复)。
另外如果两个元素哈市Code相等但equals结果不为true,HashSet会将这两个元素保存在同一个位置,并将超过一个的元素以链表方式保存,这将影响HashSet的效率。
如果重写了equals方法但没有重写hashCode方法,则HashSet可能无法正常工作,比如下面的例子。
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
public class R {
private int count;
public R(int count) {
this.count = count;
}
@Override
public String toString() {
return "R{" + "count=" + count + " # hashCode=" + this.hashCode() + \'}\';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
R r = (R) o;
return count == r.count;
}
// @Override
// public int hashCode() {
// return Objects.hash(count);
// }
public static void main(String[] args) {
Set set = new HashSet();
set.add(new R(5));
set.add(new R(-3));
set.add(new R(9));
set.add(new R(-2));
System.out.println(set.contains(new R(-3)));
System.out.println(set);
}
}
上面注释了hashCode方法,所以你将会看到下面的结果。
false
[R{count=9 # hashCode=2003749087}, R{count=5 # hashCode=1283928880}, R{count=-3 # hashCode=295530567}, R{count=-2 # hashCode=1324119927}]
取消注释,则结果就正确了
true
[R{count=5 # hashCode=36}, R{count=9 # hashCode=40}, R{count=-3 # hashCode=28}, R{count=-2 # hashCode=29}]
如何达到不能存在重复元素的目的?
“键”就是我们要存入的对象,“值”则是一个常量。这样可以确保,我们所需要的存储的信息是“键”。而“键”在Map中是不能重复的,这就保证了我们存入Set中的所有的元素都不重复。
HashSet如何过滤重复元素
调用元素HashCode获得哈希码–》判断哈希码是否相等,不相等则录入
—》相等则判断equals()后是否相等,不相等在进行 hashcode录入,相等不录入
LinkedHashSet的特征
LinkedHashSet是HashSet的一个子类,LinkedHashSet也根据HashCode的值来决定元素的存储位置,但同时它还用一个链表来维护元素的插入顺序,插入的时候即要计算hashCode又要维护链表,而遍历的时候只需要按链表来访问元素。查看LinkedHashSet的源码发现它是样的
public class LinkedHashSet<E>
extends HashSet<E>
implements Set<E>, Cloneable, java.io.Serializable {
private static final long serialVersionUID = -2851667679971038690L;
public LinkedHashSet(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor, true);
}
....
在JAVA8中, LinkedHashSet没有定义任何方法,只有四个构造函数,它的构造函数调用了父类(HashSet)的带三个参数的构造方法,父类的构造函数如下
/**
* Constructs a new, empty linked hash set. (This package private
* constructor is only used by LinkedHashSet.) The backing
* HashMap instance is a LinkedHashMap with the specified initial
* capacity and the specified load factor.
*
* @param initialCapacity the initial capacity of the hash map
* @param loadFactor the load factor of the hash map
* @param dummy ignored (distinguishes this
* constructor from other int, float constructor.)
* @throws IllegalArgumentException if the initial capacity is less
* than zero, or if the load factor is nonpositive
*/
HashSet(int initialCapacity, float loadFactor, boolean dummy) {
map = new LinkedHashMap<>(initialCapacity, loadFactor);
}
由此可知,LinkedHashSet本质上也是从LinkedHashMap而来,LinkedHashSet的所有方法都继承自HashSet, 而它能维持元素的插入顺序的性质则继承自LinkedHashMap.
下面是一个LinkedHashSet维持元素插入顺序的例子
import java.util.LinkedHashSet;
import java.util.Set;
/**
* ClassName: LinkedHashSets
* Description:
* date: 2019-11-20 17:18
*
* @author chengluchao
* @since JDK 1.8
*/
public class LinkedHashSets {
public static void main(String[] args) {
Set set = new LinkedHashSet();
set.add("abc");
set.add("efg");
set.add("hjk");
System.out.println(set);
set.remove(new String("abc"));
set.add("abc");
System.out.println(set);
}
}
输入如下
[abc, efg, hjk]
[efg, hjk, abc]
TreeSet类的特征
TreeSet实现了SortedSet接口,顾名思义这是一种排序的Set集合,查看jdk源码发现底层是用TreeMap实现的,本质上是一个红黑树原理。 正因为它是排序了的,所以相对HashSet来说,TreeSet提供了一些额外的按排序位置访问元素的方法,例如first(), last(), lower(), higher(), subSet(), headSet(), tailSet().
TreeSet的排序分两种类型,一种是自然排序,另一种是定制排序。
自然排序(在元素中写排序规则)
TreeSet 会调用compareTo方法比较元素大小,然后按升序排序。所以自然排序中的元素对象,都必须实现了Comparable接口,否则会抛出异常。对于TreeSet判断元素是否重复的标准,也是调用元素从Comparable接口继承而来额compareTo方法,如果返回0则是重复元素(两个元素I相等)。Java的常见类都已经实现了Comparable接口,下面举例说明没有实现Comparable存入TreeSet时引发异常的情况。
import java.util.Set;
import java.util.TreeSet;
/**
* ClassName: TestSets
* Description: Tree自然排序
* date: 2019-11-20 17:27
*
* @author chengluchao
* @since JDK 1.8
*/
public class TestSets {
public static void main(String[] args) {
Set set = new TreeSet();
set.add(new Err());
set.add(new Err());
set.add(new Err());
System.out.println(set);
}
}
class Err {
}
运行程序会抛出如下异常
Exception in thread "main" java.lang.ClassCastException: clc.Err cannot be cast to java.lang.Comparable
at java.util.TreeMap.compare(TreeMap.java:1294)
at java.util.TreeMap.put(TreeMap.java:538)
at java.util.TreeSet.add(TreeSet.java:255)
at clc.TestSets.main(TestSets.java:17)
将上面的Err类实现Comparable接口之后程序就能正常运行了
class Err implements Comparable{
@Override
public int compareTo(Object o) {
return 0;
}
}
还有个重要问题是,因为TreeSet会调用元素的compareTo方法,这就要求所有元素的类型都相同,否则也会发生异常。也就是说,TreeSet只允许存入同一类的元素。例如下面这个例子就会抛出类型转换异常
public static void main(String[] args) {
Set set = new TreeSet();
set.add(1);
set.add("2");
System.out.println(set);
}
运行结果
Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Date
at java.util.Date.compareTo(Date.java:131)
at java.util.TreeMap.put(TreeMap.java:568)
at java.util.TreeSet.add(TreeSet.java:255)
at clc.TestSets.main(TestSets.java:19)
定制排序(在集合中写排序规则)
TreeSet还有一种排序就是定制排序,定制排序时候,需要关联一个Comparator对象,由Comparator提供排序逻辑。下面就是一个使用Lambda表达式代替Comparator对象来提供定制排序的例子。下面是一个定制排序的列子
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
/**
* ClassName: TestSets
* Description: Tree自然排序
* date: 2019-11-20 17:27
*
* @author chengluchao
* @since JDK 1.8
*/
public class TestSets {
public static void main(String[] args) {
Set set = new TreeSet(new MyCommpare());
set.add(new M(5));
set.add(new M(3));
set.add(new M(9));
System.out.println(set);
}
}
class M {
int age;
public M(int age) {
this.age = age;
}
}
class MyCommpare implements Comparator {
@Override
public int compare(Object o1, Object o2) {
M m1 = (M) o1;
M m2 = (M) o2;
return m1.age > m2.age ? 1 : m1.age < m2.age ? -1 : 0;
}
}
当然将Comparator直接写入TreeSet初始化中也可以。如下。
import org.junit.Test;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;
/**
* ClassName: TestSets
* Description: Tree自然排序
* date: 2019-11-20 17:27
*
* @author chengluchao
* @since JDK 1.8
*/
public class TestSets {
public static void main(String[] args) {
Set set = new TreeSet(new MyCommpare());
set.add(new M(5));
set.add(new M(3));
set.add(new M(9));
System.out.println(set);
}
/**
* Description: 将Comparator直接写入TreeSet初始化中1
*
* @method: testTreeSet
* @author: chengluchao
* @date: 2019-11-21 09:41
* @param:
* @return:
*/
@Test
public void testTreeSet() {
Set set = new TreeSet(new Comparator() {
@Override
public int compare(Object o1, Object o2) {
M m1 = (M) o1;
M m2 = (M) o2;
return m1.age > m2.age ? 1 : m1.age < m2.age ? -1 : 0;
}
});
set.add(new M(5));
set.add(new M(3));
set.add(new M(9));
System.out.println(set);
}
/**
* Description: 将Comparator直接写入TreeSet初始化中
*
* @method: testTreeSetLam
* @author: chengluchao
* @date: 2019-11-21 09:41
* @param:
* @return:
*/
@Test
public void testTreeSetLam() {
Set set = new TreeSet((o1, o2) -> {
M m1 = (M) o1;
M m2 = (M) o2;
return m1.age > m2.age ? 1 : m1.age < m2.age ? -1 : 0;
});
set.add(new M(5));
set.add(new M(3));
set.add(new M(9));
System.out.println(set);
}
}
class M {
int age;
public M(int age) {
this.age = age;
}
}
class MyCommpare implements Comparator {
@Override
public int compare(Object o1, Object o2) {
M m1 = (M) o1;
M m2 = (M) o2;
return m1.age > m2.age ? 1 : m1.age < m2.age ? -1 : 0;
}
}
class Err implements Comparable {
@Override
public int compareTo(Object o) {
return 0;
}
TreeSet是依靠TreeMap来实现的。
TreeSet是一个有序集合,TreeSet中元素将按照升序排列,缺省是按照自然顺序进行排列,意味着TreeSet中元素要实现Comparable接口。
我们可以在构造TreeSet对象时,传递实现了Comparator接口的比较器对象。
Comparable和Comparator
Comparable 接口以提供自然排序顺序。
对于那些没有自然顺序的类、或者当您想要一个不同于自然顺序的顺序时,您可以实现Comparator 接口来定义您自己的排序函数。可以将Comparator传递给Collections.sort或Arrays.sort。
Comparator接口
当一个类并未实现Comparable,或者不喜欢缺省的Comaparable行为。可以实现Comparator接口
直接实现Comparator的compare接口完成自定义比较类。
例:Arrays.sort(results, new Comparator<RepDataQueryResultVO>() 数组排序 RepDataQueryExecutor
例:Collections.sort(lst,new Comparator<TaskPrintSchemeVO>()
EnumSet特征
EnumSet顾名思义就是专为枚举类型设计的集合,因此集合元素必须是枚举类型,否则会抛出异常。 EnumSet集合也是有序的,其顺序就是Enum类内元素定义的顺序。 EnumSet存取的速度非常快,批量操作的速度也很快。EnumSet主要提供以下方法,allOf, complementOf, copyOf, noneOf, of, range等。注意到EnumSet并没有提供任何构造函数,要创建一个EnumSet集合对象,只需要调用allOf等方法,下面是一个EnumSet的例子。
import java.util.EnumSet;
/**
* ClassName: EnumSets
* Description:
* date: 2019-11-21 09:59
*
* @author chengluchao
* @since JDK 1.8
*/
public class EnumSets {
public static void main(String[] args) {
EnumSet es1 = EnumSet.allOf(Season.class);
System.out.println(es1);
EnumSet es2 = EnumSet.noneOf(Season.class);
es2.add(Season.WINTER);
es2.add(Season.SUMER);
System.out.println(es2);
EnumSet es3 = EnumSet.of(Season.WINTER, Season.SUMER);
System.out.println(es3);
EnumSet es4 = EnumSet.range(Season.SUMER,Season.WINTER );
System.out.println(es4);
EnumSet es5 = EnumSet.complementOf(es4);
System.out.println(es5);
}
}
enum Season {
SPRING, SUMER, FALL, WINTER
}
执行结果
[SPRING, SUMER, FALL, WINTER]
[SUMER, WINTER]
[SUMER, WINTER]
[SUMER, FALL, WINTER]
[SPRING]
几种Set的比较:
HashSet外部无序地遍历成员。
成员可为任意Object子类的对象,但如果覆盖了equals方法,同时注意修改hashCode方法。
TreeSet外部有序地遍历成员;
附加实现了SortedSet, 支持子集等要求顺序的操作
成员要求实现Comparable接口,或者使用Comparator构造TreeSet。成员一般为同一类型。
LinkedHashSet外部按成员的插入顺序遍历成员
成员与HashSet成员类似
HashSet是基于Hash算法实现的,其性能通常都优于TreeSet。我们通常都应该使用HashSet,在我们需要排序的功能时,我们才使用TreeSet。
HashSet的元素存放顺序和我们添加进去时候的顺序没有任何关系,而LinkedHashSet 则保持元素的添加顺序。TreeSet则是对我们的Set中的元素进行排序存放。
一般来说,当您要从集合中以有序的方式抽取元素时,TreeSet实现就会有用处。为了能顺利进行,添加到 TreeSet 的元素必须是可排序的。 而您同样需要对添加到TreeSet中的类对象实现 Comparable 接口的支持。一般说来,先把元素添加到 HashSet,再把集合转换为 TreeSet 来进行有序遍历会更快。
各种Set集合性能分析
- HashSet和TreeSet是Set集合中用得最多的I集合。HashSet总是比TreeSet集合性能好,因为HashSet不需要额维护元素的顺序。
- LinkedHashSet需要用额外的链表维护元素的插入顺序,因此在插入时性能比HashSet低,但在迭代访问(遍历)时性能更高。因为插入的时候即要计算hashCode又要维护链表,而遍历的时候只需要按链表来访问元素。
- EnumSet元素是所有Set元素中性能最好的,但是它只能保存Enum类型的元素
Map
集合框架的第二类接口树。
它提供了一组键值的映射。其中存储的每个对象都有一个相应的关键字(key),关键字决定了对象在Map中的存储位置。
关键字应该是唯一的,每个key 只能映射一个value。
实现类:
HashMap、TreeMap、LinkedHashMap、Hashtable等
- HashMap:键值对,key不能重复,但是value可以重复;key的实现就是HashSet;value对应着放;允许null的键或值;
- Hashtable:线程安全的,不允许null的键或值;
- Properties::key和value都是String类型,用来读配置文件;
- TreeMap:对key排好序的Map; key 就是TreeSet, value对应每个key; key要实现Comparable接口或TreeMap有自己的构造器;
- LinkedHashMap: 此实现与HashMap的不同之处在于,后者维护着一个运行于所有条目的双重链接列表。存储的数据是有序的。
HashMap:
- Map 主要用于存储键(key)值(value)对,根据键得到值,因此键不允许重复,但允许值重复。
- HashMap 是一个最常用的Map,它根据键的HashCode值存储数据,根据键可以直接获取它的值,具有很快的访问速度。
- HashMap最多只允许一条记录的键为Null;允许多条记录的值为 Null;
- HashMap不支持线程的同步,即任一时刻可以有多个线程同时写HashMap;可能会导致数据的不一致。如果需要同步,可以用 Collections的synchronizedMap方法使HashMap具有同步的能力。
HashMap实现原理—散列
Hash哈希算法的意义在于提供了一种快速存取数据的方法,它用一种算法建立键值与真实值之间的对应关系。散列表又称为哈希表。散列表算法的基本思想是:以结点的关键字为自变量,通过一定的函数关系(散列函数)计算出对应的函数值,以这个值作为该结点存储在散列表中地址。
当散列表中的元素存放太满,就必须进行再散列,将产生一个新的散列表,所有元素存放到新的散列表中,原先的散列表将被删除。在Java语言中,通过负载因子(load factor)来决定何时对散列表进行再散列。例如:如果负载因子0.75,当散列表中已经有75%位置已经放满,那么将进行再散列。
负载因子越高(越接近1.0),内存的使用效率越高,元素的寻找时间越长。负载因子越低(越接近0.0),元素的寻找时间越短,内存浪费越多。
何时需重写equals?
当一个类有自己特有的“逻辑相等”概念(不同于对象身份的概念);
Object类仅仅提供了一个对引用的比较,如果两个引用不是同一个那就返回false,这是无法满足大多数对象比较的需要的,所以要覆盖;
使用==操作符检查实参是否为指向对象的引用”
使用instanceof操作符检查实参是否为正确的类型
把实参转换到正确的类型;
对于该类中每一个“关键”域,检查实参中的域与当前对象中对应的域值是否匹配。对于既不是float也不是double类型的基本类型的域,可以使用==操作符进行比较;对于对象引用类型的域,可以递归地调用所引用的对象的equals方法,对于float和double类型的域,先转换成int或long类型的值,然后使用==操作符比较;
当你编写完成了equals方法之后,应该问自己三个问题:它是否是对称的、传 递的、一致的? 如果答案是否定的,那么请找到 这些特性未能满足的原因,再修改equals方法的代码
equals()和hashCode()同时覆写
尤其强调当一个对象被当作键值(或索引)来使用的时候要重写这两个方法;
覆写equals后,两个不同实例可能在逻辑上相等,但是根据Object.hashCode方法却产生不同的散列码,违反“相等的对象必须具有相等的散列码”。
导致,当你用其中的一个作为键保存到hashMap、hasoTable或hashSet中,再以“相等的”找另 一个作为键值去查找他们的时候,则根本找不到
不同类型的hashCode取值
- 如果该域是布尔型的,计算(f?0:1)
- 如果是char,short,byte或int,计算(int)f
- 如果是long类型,计算(int)(f^(f>>>32))
- 如果是float类型,计算Float.floatToIntBits(f)
- 如果是double类型,计算Dobule.doubleToLongBits(f)
- 如果该域是一个对象引用,递归调用hashCode
- 如果该域是一个数组,则把每个元素当做单独的域来处理,对每个重要的元素计算一个散列码
Map集合比较:
- HashMap的存入顺序和输出顺序无关。
- LinkedHashMap 则保留了键值对的存入顺序。
- TreeMap则是对Map中的元素进行排序。
- 因为HashMap和LinkedHashMap 存储数据的速度比直接使用TreeMap 要快,存取效率要高。
- 当完成了所有的元素的存放后,我们再对整个的Map中的元素进行排序。这样可以提高整个程序的运行的效率,缩短执行时间。
注意:TreeMap中是根据键(Key)进行排序的。而如果我们要使用TreeMap来进行正常的排序的话,Key 中存放的对象必须实现Comparable 接口。
Map常用方法:
- Object put(Object key,Object value):用来存放一个键-值对Map中
- Object remove(Object key):根据key(键),移除键-值对,并将值返回
- void putAll(Map mapping) :将另外一个Map中的元素存入当前的Map中
- void clear() :清空当前Map中的元素
- Object get(Object key) :根据key(键)取得对应的值
- boolean containsKey(Object key) :判断Map中是否存在某键(key)
- boolean containsValue(Object value):判断Map中是否存在某值(value)
- public Set keySet() :返回所有的键(key),并使用Set容器存放
- public Collection values() :返回所有的值(Value),并使用Collection存放
- public Set entrySet() :返回一个实现 Map.Entry 接口的元素 Set
集合遍历
- 增强for循环 for(Obj o:c){syso(o)}
- 使用iterator , Iterator it=c.iterator;
while(it.hasNext()){Object o = it.next()} - 普通循环:for(Iterator it=c.iterator();it.hasNext();){it.next() }
总结
- ArrayList: 元素单个,效率高,多用于查询
- Vector: 元素单个,线程安全,多用于查询
- LinkedList:元素单个,多用于插入和删除
- HashMap: 元素成对,元素可为空
- shTable: 元素成对,线程安全,元素不可为空
HashMap和Hashtable的区别:
HashMap和Hashtable都是java的集合类,都可以用来存放java对象,这是他们的相同点
以下是他们的区别:
- 历史原因:
Hashtable是基于陈旧的Dictionary类的,HashMap是java 1.2引进的Map接口的一个现实。 - 同步性:
hashtable是同步的,这个类中的一些方法保证了Hashtable中的对象是线程安全的,而HashMap则是异步的,因此HashMap中的对象并不是线程安全的,因为同步的要求会影响执行的效率,所以如果你不需要线程安全的结合那么使用HashMap是一个很好的选择,这样可以避免由于同步带来的不必要的性能开销,从而提高效率,我们一般所编写的程序都是异步的,但如果是服务器端的代码除外。 - 值:
HashMap可以让你将空值作为一个表的条目的key或value
Hashtable是不能放入空值(null)的
ArrayList和Vector的区别:
ArrayList与Vector都是java的集合类,都是用来存放java对象,这是他们的相同点,
区别:
- 同步性:
Vector是同步的,这个类的一些方法保证了Vector中的对象的线程安全的,而ArrayList则是异步的,因此ArrayList中的对象并不 是线程安全的,因为同步要求会影响执行的效率,所以你不需要线程安全的集合那么使用ArrayList是一个很好的选择,这样可以避免由于同步带来的不必 要的性能开销。 - 数据增长:
从内部实现的机制来讲,ArrayList和Vector都是使用数组(Array)来控制集合中的对象,当你向两种类型中增加元素的时候,如果元素的数目超过了内部数组目前的长度他们都需要扩展内部数组的长度,Vector缺省情况下自动增长原来一倍的数组长度,ArrayList是原来的50%,所以最后你获得的这个集合所占的空间总是比你实际需要的要大,所以如果你要在集合中保存大量的数据,那么使用Vector有一些优势,因为你可以通过设置集合的初始大小来避免不必要的资源开销。
总结:
- 如果要求线程安全,使用Vector,Hashtable
- 如果不要求线程安全,使用ArrayList,LinkedList,HashMap
- 如果要求键值对,则使用HashMap,Hashtable
- 如果数据量很大,又要求线程安全考虑Vector
arraylist和linkedlist联系与区别
- ArrayList是实现了基于动态数组的数据结构,LinkedList基于链表的数据结构。
- 对于随机访问get和set,ArrayList觉得优于LinkedList,因为LinkedList要移动指针。
- 对于新增和删除操作add和remove,LinedList比较占优势,因为ArrayList要移动数据。 这一点要看实际情况的。若只对单条数据插入或删除,ArrayList的速度反而优于LinkedList。但若是批量随机的插入删除数据,LinkedList的速度大大优于ArrayList. 因为ArrayList每插入一条数据,要移动插入点及之后的所有数据。
HashMap与TreeMap联系与区别
- HashMap通过hashcode对其内容进行快速查找,而TreeMap中所有的元素都保持着某种固定的顺序,如果你需要得到一个有序的结果你就应该使用TreeMap(HashMap中元素的排列顺序是不固定的)。
- 在Map 中插入、删除和定位元素,HashMap是最好的选择。但如果您要按自然顺序或自定义顺序遍历键,那么TreeMap会更好。使用HashMap要求添加的键类明确定义了hashCode()和 equals()的实现。
两个map中的元素一样,但顺序不一样,导致hashCode()不一样。
同样做测试:
在HashMap中,同样的值的map,顺序不同,equals时,false;
而在treeMap中,同样的值的map,顺序不同,equals时,true,说明,treeMap在equals()时是整理了顺序了的。