PageSourceSearch

https://patternize.github.io/assets/js/2e501da1.4f66e4ef.js

js patternize.github.io collected 2026-10-03 09:45:59 UTC 4,169 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkpatternize_io=self.webpackChunkpatternize_io||[]).push([[6626],{15680:(e,r,t)=>{t.d(r,{xA:()=>s,yg:()=>y});var a=t(96540);function n(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,a)}return t}function o(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?p(Object(t),!0).forEach((function(r){n(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):p(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function l(e,r){if(null==e)return{};var t,a,n=function(e,r){if(null==e)return{};var t,a,n={},p=Object.keys(e);for(a=0;a<p.length;a++)t=p[a],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(e);for(a=0;a<p.length;a++)t=p[a],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}var i=a.createContext({}),u=function(e){var r=a.useContext(i),t=r;return e&&(t="function"==typeof e?e(r):o(o({},r),e)),t},s=function(e){var r=u(e.components);return a.createElement(i.Provider,{value:r},e.children)},c="mdxType",m={inlineCode:"code",wrapper:function(e){var r=e.children;return a.createElement(a.Fragment,{},r)}},g=a.forwardRef((function(e,r){var t=e.components,n=e.mdxType,p=e.originalType,i=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),c=u(t),g=n,y=c["".concat(i,".").concat(g)]||c[g]||m[g]||p;return t?a.createElement(y,o(o({ref:r},s),{},{components:t})):a.createElement(y,o({ref:r},s))}));function y(e,r){var t=arguments,n=r&&r.mdxType;if("string"==typeof e||n){var p=t.length,o=new Array(p);o[0]=g;var l={};for(var i in r)hasOwnProperty.call(r,i)&&(l[i]=r[i]);l.originalType=e,l[c]="string"==typeof e?e:n,o[1]=l;for(var u=2;u<p;u++)o[u]=t[u];return a.createElement.apply(null,o)}return a.createElement.apply(null,t)}g.displayName="MDXCreateElement"},84365:(e,r,t)=>{t.r(r),t.d(r,{assets:()=>s,contentTitle:()=>i,default:()=>y,frontMatter:()=>l,metadata:()=>u,toc:()=>c});var a=t(58168),n=t(98587),p=(t(96540),t(15680));const o=["components"],l={id:"TreeMap",title:"TreeMap",sidebar_label:"TreeMap"},i=void 0,u={unversionedId:"Language/Java/Map/TreeMap",id:"Language/Java/Map/TreeMap",title:"TreeMap",description:"Basics",source:"@site/docs/Language/Java/Map/TreeMap.md",sourceDirName:"Language/Java/Map",slug:"/Language/Java/Map/TreeMap",permalink:"/Language/Java/Map/TreeMap",draft:!1,tags:[],version:"current",frontMatter:{id:"TreeMap",title:"TreeMap",sidebar_label:"TreeMap"},sidebar:"CS Core",previous:{title:"LinkedHashMap",permalink:"/Language/Java/Map/LinkedHashMap"},next:{title:"Runtime",permalink:"/Language/Java/Map/Runtime"}},s={},c=[{value:"Basics",id:"basics",level:2},{value:"TreeMap vs HashMap",id:"treemap-vs-hashmap",level:2}],m={toc:c},g="wrapper";function y(e){let r=e.components,t=(0,n.A)(e,o);return(0,p.yg)(g,(0,a.A)({},m,t,{components:r,mdxType:"MDXLayout"}),(0,p.yg)("h2",{id:"basics"},"Basics"),(0,p.yg)("ul",null,(0,p.yg)("li",{parentName:"ul"},"TreeMap is ordered by Keys"),(0,p.yg)("li",{parentName:"ul"},"put(), get(), remove() all cost O(logN) in the worst scenario"),(0,p.yg)("li",{parentName:"ul"},"Iteration order predictable"),(0,p.yg)("li",{parentName:"ul"},"Allows only Values to be null, Keys cannot be null")),(0,p.yg)("h2",{id:"treemap-vs-hashmap"},"TreeMap vs HashMap"),(0,p.yg)("ul",null,(0,p.yg)("li",{parentName:"ul"},"TreeMap are naturally sorted by order of key, HashMap is not:")),(0,p.yg)("pre",null,(0,p.yg)("code",{parentName:"pre"},"TreeMap<Integer, Integer> tm = new TreeMap<>();\ntm.put(3, 1);\ntm.put(2, 2);\ntm.put(1, 10);\ntm.put(-100, 2);\ntm.values(); //[2, 10, 2, 1]\n\nHashMap<Integer, Integer> hm = new HashMap<>();\nhm.put(3, 1);\nhm.put(2, 2);\nhm.put(1, 10);\nhm.put(-100, 2);\nhm.values(); // [10, 2, 1, 2]\n")))}y.isMDXComponent=!0}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.