{"id":327076,"date":"2022-01-10T08:45:05","date_gmt":"2022-01-10T08:45:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=327076"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=327076","title":{"rendered":"<span>Java: \u0434\u0435\u043b\u0430\u0435\u043c Valhalla \u0441\u0430\u043c\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\" class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0418\u0434\u0435\u044f<\/h2>\n<p>\u0412 Java \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 &#8212; \u044d\u0442\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u0434\u0430\u043d\u043d\u044b\u0435. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 64 \u0431\u0438\u0442\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0440\u0430\u0432\u0435\u043d 16 \u0431\u0430\u0439\u0442\u0430\u043c. \u0422\u0430\u043a\u0436\u0435 Java \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e 8 \u0431\u0430\u0439\u0442, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u0440\u0430\u0442\u0435\u043d 8 \u0431\u0430\u0439\u0442\u0430\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u0451\u0440\u0442\u043a\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a Integer, Double \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u043e 24 \u0431\u0430\u0439\u0442\u0430, \u0447\u0442\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. <\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h2>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 Java \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u0443\u0447\u0435, \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043d\u0438\u0445 \u043b\u0435\u0436\u0430\u0442 \u0432 List&lt;?>, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043b\u044f int \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 28 \u0431\u0430\u0439\u0442 (\u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043e\u043a) \u0432\u043c\u0435\u0441\u0442\u043e 4 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0414\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 JVM \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 Boolean, Byte, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Integer, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u0435\u0441\u0442\u0438 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e 4 \u0431\u0430\u0439\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0438\u043d\u0430\u0447\u0435: \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c, \u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0438 \u0432\u0435\u0441\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u0442 \u043d\u0435\u0433\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (boolean, byte, short, char, int, float, long, double) \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>\u041f\u0440\u0438 \u0432\u0437\u044f\u0442\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/RigelGL\/MemoryEfficientList\" rel=\"noopener noreferrer nofollow\">github<\/a>, \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0441\u043e\u043a\u0440\u0430\u0449\u0451\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0440\u0435\u0437 Unsafe, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 Reflect, \u043d\u043e \u0441 \u043d\u0438\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043d\u0438\u0436\u0435 \u043d\u0430 20-30%.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Unsafe:<\/p>\n<pre><code class=\"java\">private static final Unsafe unsafe;  static {     try {         Field theUnsafe = Unsafe.class.getDeclaredField(\"theUnsafe\");         theUnsafe.setAccessible(true);         unsafe = (Unsafe) theUnsafe.get(null);     } catch (Exception e) {       throw new AssertionError(e);     } } <\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0435\u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u043b\u044f\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"java\">private List&lt;Field> getCorrectFields(Class&lt;?> clazz) { List&lt;Field> correctFields = new ArrayList&lt;>(); for(Field f : clazz.getDeclaredFields()) {     \/\/ \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u043b\u044f     if((f.getModifiers() &amp; 8) == 0)       correctFields.add(f);   }   return correctFields; }<\/code><\/pre>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0412 \u043c\u0430\u0441\u0441\u0438\u0432 <code>fieldOffsets<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c offset \u043f\u043e\u043b\u044f, \u043d\u0443\u0436\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b Unsafe, \u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 <code>fieldTypes<\/code> \u0435\u0433\u043e \u0442\u0438\u043f, \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0431\u043e\u0440\u043a\u0438\/\u0440\u0430\u0437\u0431\u043e\u0440\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"java\">private final byte[] fieldTypes; private final long[] fieldOffsets; private int objectByteSize;   private void initFields(List&lt;Field> correctFields) {   for(int i = 0; i &lt; fieldTypes.length; i++) {         Field f = correctFields.get(i);         fieldOffsets[i] = unsafe.objectFieldOffset(f);         f.setAccessible(true);                if(f.getType() == boolean.class) {           fieldTypes[i] = TYPE_BOOLEAN;           objectByteSize += 1;         }         else if(f.getType() == int.class) {           fieldTypes[i] = TYPE_INT;           objectByteSize += 4;         }     } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0451 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e, \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 fields \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0430\u043c\u0438 \u043f\u043e\u043b\u044f, \u0432 fieldTypes \u0438\u0445 \u0442\u0438\u043f (\u0431\u0430\u0439\u0442 \u043e\u0442 0 \u0434\u043e 7), \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/p>\n<pre><code class=\"java\">private Object buildNewObject() throws Exception {       return unsafe.allocateInstance(clazz); }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0437\u043d\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445 \u0438 \u0437\u043d\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u044c. \u0417\u0430\u043f\u0440\u043e\u0441\u0438\u043c \u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0430\u043c\u044f\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435:<\/p>\n<pre><code class=\"java\">\/\/ \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 public MemoryEfficientList(Class&lt;?> clazz, int size) {   this.clazz = clazz;   List&lt;Field> correctFields = getCorrectFields(clazz);      fieldTypes = new byte[correctFields.size()];     fieldOffsets = new long[correctFields.size()];    initFields(correctFields);        dataSize = size;   \/\/ \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043f\u0430\u043c\u044f\u0442\u044c     dataAddress = unsafe.allocateMemory(objectByteSize * size);      try {         \/\/ \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439         firstFast = buildNewObject();         secondFast = buildNewObject();         fastInternal = buildNewObject();         oldValue = buildNewObject();     } catch(Exception ignored) {     } }<\/code><\/pre>\n<p><code>unsafe.allocateMemory<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441 \u043d\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>unsafe.getInt(dataArray + byteOffset)<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 4 \u0431\u0430\u0439\u0442\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 dataArray + byteOffset.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0431\u0430\u0439\u0442\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443:<\/p>\n<pre><code class=\"java\">private void decomposeObject(int pos, Object object) {         int offset = pos * objectByteSize;          for(int i = 0; i &lt; fieldTypes.length; i++) {             long fo = fieldOffsets[i];              switch(fieldTypes[i]) {                 case TYPE_BOOLEAN: {                     unsafe.putByte(dataAddress + offset,                                     (byte) (unsafe.getBoolean(object, fo) ? 1 : 0));                     offset += 1;                     break;                 }                  case TYPE_INT: {                     unsafe.putInt(dataAddress + offset, unsafe.getInt(object, fo));                     offset += 4;                     break;                 }             }         }     }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u0441\u0431\u043e\u0440\u043a\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0437 \u0431\u0430\u0439\u0442:<\/p>\n<pre><code class=\"java\">private void composeObject(int pos, Object object) {         long offset = pos * objectByteSize;          for(int i = 0; i &lt; fieldTypes.length; i++) {             long fo = fieldOffsets[i];             switch(fieldTypes[i]) {                 case TYPE_BOOLEAN: {                     unsafe.putBoolean(object, fo,                                        unsafe.getByte(dataAddress + offset) == 1);                     offset += 1;                     break;                 }                                  case TYPE_INT: {                     unsafe.putInt(object, fo, unsafe.getInt(dataAddress + offset));                     offset += 4;                     break;                 }             }         }     }<\/code><\/pre>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<pre><code class=\"java\">public boolean add(Object o) {     \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u043e\u043d\u0435\u0446 \u043c\u0430\u0441\u0441\u0438\u0432\u0430     decomposeObject(size, o);     size += 1;     return true; }<\/code><\/pre>\n<p>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/p>\n<pre><code class=\"java\">public Object get(int index) {     \/\/ \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 getFast \u0438 getFast2 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f     \/\/ \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435     \/\/ \u043e\u0431\u044a\u0435\u043a\u0442\u044b: firstFast \u0438 secondFast     Object result = buildNewObject();     composeObject(index, result);     return result; }<\/code><\/pre>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443:<\/p>\n<pre><code class=\"java\">public Object remove(int index) {         composeObject(index, oldValue);          final int newSize = size - 1;          if(newSize > index)             unsafe.copyMemory((index + 1) * objectByteSize,                                index * objectByteSize,                                (newSize - index) * objectByteSize);            size = newSize;         return oldValue;     }<\/code><\/pre>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0442\u0435\u0441\u0442\u0430\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>CPU<\/p>\n<\/td>\n<td>\n<p>Intel Core i7 7600<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>RAM<\/p>\n<\/td>\n<td>\n<p>12GB, 2400 MHz<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>JVM<\/p>\n<\/td>\n<td>\n<p>OpenJDK 13.0.2, windows<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0411\u0435\u0437 \u0441\u043a\u043e\u0431\u043e\u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0442\u0435\u0441\u0442\u0430 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445, \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u0441\u0440\u0435\u0434\u043d\u0435\u0435.<\/p>\n<p>MEL = MemoryEfficientList<\/p>\n<p>\u0422\u0435\u0441\u0442 0, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 N int \u0432 \u043c\u0430\u0441\u0441\u0438\u0432. \u041c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. <code>int[]<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>N<\/p>\n<\/td>\n<td>\n<p>ArrayList<\/p>\n<\/td>\n<td>\n<p>MEL<\/p>\n<\/td>\n<td>\n<p>int[]<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>10 000 000<\/p>\n<\/td>\n<td>\n<p>0.18 (0.27)<\/p>\n<\/td>\n<td>\n<p>0.15 (0.22)<\/p>\n<\/td>\n<td>\n<p>0.09 (0.10)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>1 000 000<\/p>\n<\/td>\n<td>\n<p>0.019 ( 0.037)<\/p>\n<\/td>\n<td>\n<p>0.015 (0.023)<\/p>\n<\/td>\n<td>\n<p>0.01 (0.01)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u0435\u043d \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f).<\/p>\n<p>\u0422\u0435\u0441\u0442 1, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 N \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 int, \u0437\u0430\u0442\u0435\u043c N \u0440\u0430\u0437 \u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 2 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430, \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0447\u0435\u043a \u0441\u0443\u043c\u043c\u0443.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f ArrayList<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">for(int i = 0; i &lt; n; i++)   al.add(r.nextInt());  for(int i = 0; i &lt; n; i++) {     int pos1 = r.nextInt(n);     int pos2 = r.nextInt(n);     Integer a = al.get(pos1);     Integer b = al.get(pos2);     al.set(pos1, b);     al.set(pos2, a); }<\/code><\/pre>\n<\/div>\n<\/details>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>N<\/p>\n<\/td>\n<td>\n<p>ArrayList&lt;Integer><\/p>\n<\/td>\n<td data-colwidth=\"167\" width=\"167\">\n<p>MEL<\/p>\n<\/td>\n<td>\n<p>MEL + getFast<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>10 000 000<\/p>\n<\/td>\n<td>\n<p>2.51 (2.99)<\/p>\n<\/td>\n<td data-colwidth=\"167\" width=\"167\">\n<p>1.61 (1.86)<\/p>\n<\/td>\n<td>\n<p>1.56 (1.73)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>1 000 000<\/p>\n<\/td>\n<td>\n<p>0.17 (0.19)<\/p>\n<\/td>\n<td data-colwidth=\"167\" width=\"167\">\n<p>0.07 (0.09)<\/p>\n<\/td>\n<td>\n<p>0.06 (0.08)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442: 24 \u0431\u0430\u0439\u0442\u0430. 4 \/ 28 = 14% \u043e\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 ArrayList&lt;Integer>.<\/p>\n<p>\u0422\u0435\u0441\u0442 2, \u0440\u0435\u0448\u0435\u0442\u043e \u042d\u0440\u0430\u0442\u043e\u0441\u0444\u0435\u043d\u0430, \u043f\u043e\u0438\u0441\u043a \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 1 \u0434\u043e N<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f ArrayList<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">for(int i = 0; i &lt; n; i++)     alIs.add(true);     alIs.set(0, false);     alIs.set(1, false);     for(int i = 0; i &lt; n; i++) {         if(alIs.get(i) &amp;&amp; i * i > 0) {             for(int j = i * i; j &lt; n; j += i)               alIs.set(j, false);             alResult.add(i);       } }<\/code><\/pre>\n<\/div>\n<\/details>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>N<\/p>\n<\/td>\n<td>\n<p>ArrayList<\/p>\n<\/td>\n<td>\n<p>MEL<\/p>\n<\/td>\n<td>\n<p>MEL + getFast<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>10 000 000<\/p>\n<\/td>\n<td>\n<p>1.00 (1.05)<\/p>\n<\/td>\n<td>\n<p>0.40 (0.41)<\/p>\n<\/td>\n<td>\n<p>0.37 (0.39)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>1 000 000<\/p>\n<\/td>\n<td>\n<p>0.035 (0.047)<\/p>\n<\/td>\n<td>\n<p>0.030 (0.040)<\/p>\n<\/td>\n<td>\n<p>0.023 (0.036)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438: 4 \u0431\u0430\u0439\u0442\u0430 (\u0441\u0441\u044b\u043b\u043a\u0430 \u0432 ArrayList) \u043f\u0440\u043e\u0442\u0438\u0432 1 \u0431\u0430\u0439\u0442\u0430 \u0432 MEL = 25% \u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0435\u0437 \u0443\u0447\u0451\u0442\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0432 \u043e\u0431\u044a\u0451\u043c\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<p>\u0422\u0435\u0441\u0442 3, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0442\u0435\u0441\u0442\u0443, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e Integer \u0431\u0443\u0434\u0435\u0442 Vec3{float x, y, z}.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>N<\/p>\n<\/td>\n<td>\n<p>ArrayList<\/p>\n<\/td>\n<td>\n<p>MEL<\/p>\n<\/td>\n<td>\n<p>MEL + getFast<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>10 000 000<\/p>\n<\/td>\n<td>\n<p>2.24 (2.40)<\/p>\n<\/td>\n<td>\n<p>1.87 (1.91)<\/p>\n<\/td>\n<td>\n<p>1.67 (1.71)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>1 000 000<\/p>\n<\/td>\n<td>\n<p>0.16 (0.18)<\/p>\n<\/td>\n<td>\n<p>0.15 (0.16)<\/p>\n<\/td>\n<td>\n<p>0.13 (0.14)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0439.<\/p>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438: 12 \u0431\u0430\u0439\u0442 \u043f\u0440\u043e\u0442\u0438\u0432 32 + 4 = 33% \u043e\u0442 \u043e\u0431\u044a\u0451\u043c\u0430 ArrayList.<\/p>\n<p>\u0422\u0435\u0441\u0442 4, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043f\u0435\u0440\u0432\u043e\u043c\u0443, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e Integer \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442:<\/p>\n<pre><code class=\"java\">public class LargeObject {     boolean x, y, z, w;     int i, j, k;     float a, b, c, d, e;     double g, h;     long m, n, o, p; }  \/\/ 84 \u0431\u0430\u0439\u0442\u0430<\/code><\/pre>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>N<\/p>\n<\/td>\n<td>\n<p>ArrayList<\/p>\n<\/td>\n<td>\n<p>MEL<\/p>\n<\/td>\n<td>\n<p>MEL + getFast<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>10 000 000<\/p>\n<\/td>\n<td>\n<p>2.53 (2.64)<\/p>\n<\/td>\n<td>\n<p>5.81 (5.94)<\/p>\n<\/td>\n<td>\n<p>5.09 (5.59)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>1 000 000<\/p>\n<\/td>\n<td>\n<p>0.15 (0.16)<\/p>\n<\/td>\n<td>\n<p>0.53 (0.56)<\/p>\n<\/td>\n<td>\n<p>0.47 (0.48)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0417\u0434\u0435\u0441\u044c MEL \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 ArrayList, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u0441\u0432\u0430\u043f\u0430\u0442\u044c 84 \u0431\u0430\u0439\u0442\u0430, \u0432\u043c\u0435\u0441\u0442\u043e 4.<\/p>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438: 84 + 16 + 4 (\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435) + 4 \/ 84 = 77% \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 ArrayList.<\/p>\n<p>\u0422\u0430\u043a \u043f\u0440\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0438 \u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d ~20 \u0431\u0430\u0439\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 MEL \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043d\u0438\u0437\u043a\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 toArray, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u0441\u0443\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 N \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u043a\u0443\u0447\u0435. \u042d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 Collections.sort, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f MEL \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438.<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0437\u0430 \u0441\u0447\u0451\u0442 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0451\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0432\u0435\u0440\u043d\u044b\u043c. \u041f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 20-60% \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0437\u0430\u0434\u0430\u0447\u0438. \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0431\u043e\u043b\u044c\u0448\u0438\u0435 (\u0431\u043e\u043b\u044c\u0448\u0435 20 \u0431\u0430\u0439\u0442 \u0434\u0430\u043d\u043d\u044b\u0445) \u0442\u043e \u0440\u0430\u0437\u0443\u043c\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ArrayList.<\/p>\n<p>\u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0435\u0439: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041d\u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438.<\/p>\n<p>\u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0437\u0430 \u0441\u0447\u0451\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 compose\/decomposeObject. \u0421\u0435\u0439\u0447\u0430\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0446\u0438\u043a\u043b, \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0430\u0439\u0442 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0451\u0442 \u0446\u0438\u043a\u043b \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u043c\u0430\u043d\u0434, \u0443\u0431\u0435\u0440\u0451\u0442 switch-case \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0439.<\/p>\n<\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/599003\/\"> https:\/\/habr.com\/ru\/post\/599003\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\" class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u0418\u0434\u0435\u044f<\/h2>\n<p>\u0412 Java \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 &#8212; \u044d\u0442\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438 \u0434\u0430\u043d\u043d\u044b\u0435. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 64 \u0431\u0438\u0442\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0440\u0430\u0432\u0435\u043d 16 \u0431\u0430\u0439\u0442\u0430\u043c. \u0422\u0430\u043a\u0436\u0435 Java \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e 8 \u0431\u0430\u0439\u0442, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u0440\u0430\u0442\u0435\u043d 8 \u0431\u0430\u0439\u0442\u0430\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u0451\u0440\u0442\u043a\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a Integer, Double \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u043e 24 \u0431\u0430\u0439\u0442\u0430, \u0447\u0442\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. <\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h2>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 Java \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u0443\u0447\u0435, \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043d\u0438\u0445 \u043b\u0435\u0436\u0430\u0442 \u0432 List&lt;?>, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043b\u044f int \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 28 \u0431\u0430\u0439\u0442 (\u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043e\u043a) \u0432\u043c\u0435\u0441\u0442\u043e 4 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0414\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 JVM \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 Boolean, Byte, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Integer, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u0435\u0441\u0442\u0438 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043e 4 \u0431\u0430\u0439\u0442 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0438\u043d\u0430\u0447\u0435: \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c, \u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0438 \u0432\u0435\u0441\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u0442 \u043d\u0435\u0433\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 (boolean, byte, short, char, int, float, long, double) \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<p>\u041f\u0440\u0438 \u0432\u0437\u044f\u0442\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/RigelGL\/MemoryEfficientList\" rel=\"noopener noreferrer nofollow\">github<\/a>, \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0441\u043e\u043a\u0440\u0430\u0449\u0451\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0440\u0435\u0437 Unsafe, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 Reflect, \u043d\u043e \u0441 \u043d\u0438\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043d\u0438\u0436\u0435 \u043d\u0430 20-30%.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Unsafe:<\/p>\n<pre><code class=\"java\">private static final Unsafe unsafe;  static {     try {         Field theUnsafe = Unsafe.class.getDeclaredField(\"theUnsafe\");         theUnsafe.setAccessible(true);         unsafe = (Unsafe) theUnsafe.get(null);     } catch (Exception e) {       throw new AssertionError(e);     } } <\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0435\u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u043b\u044f\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"java\">private List&lt;Field> getCorrectFields(Class&lt;?> clazz) { List&lt;Field> correctFields = new ArrayList&lt;>(); for(Field f : clazz.getDeclaredFields()) {     \/\/ \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u043b\u044f     if((f.getModifiers() &amp; 8) == 0)       correctFields.add(f);   }   return correctFields; }<\/code><\/pre>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0412 \u043c\u0430\u0441\u0441\u0438\u0432 <code>fieldOffsets<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c offset \u043f\u043e\u043b\u044f, \u043d\u0443\u0436\u043d\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b Unsafe, \u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 <code>fieldTypes<\/code> \u0435\u0433\u043e \u0442\u0438\u043f, \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0431\u043e\u0440\u043a\u0438\/\u0440\u0430\u0437\u0431\u043e\u0440\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"java\">private final byte[] fieldTypes; private final long[] fieldOffsets; private int objectByteSize;   private void initFields(List&lt;Field> correctFields) {   for(int i = 0; i &lt; fieldTypes.length; i++) {         Field f = correctFields.get(i);         fieldOffsets[i] = unsafe.objectFieldOffset(f);         f.setAccessible(true);                if(f.getType() == boolean.class) {           fieldTypes[i] = TYPE_BOOLEAN;           objectByteSize += 1;         }         else if(f.getType() == int.class) {           fieldTypes[i] = TYPE_INT;           objectByteSize += 4;         }     } }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0451 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e, \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 fields \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0430\u043c\u0438 \u043f\u043e\u043b\u044f, \u0432 fieldTypes \u0438\u0445 \u0442\u0438\u043f (\u0431\u0430\u0439\u0442 \u043e\u0442 0 \u0434\u043e 7), \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f:<\/p>\n<pre><code class=\"java\">private Object buildNewObject() throws Exception {       return unsafe.allocateInstance(clazz); }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0437\u043d\u0430\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445 \u0438 \u0437\u043d\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u044c. \u0417\u0430\u043f\u0440\u043e\u0441\u0438\u043c \u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0430\u043c\u044f\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435:<\/p>\n<pre><code class=\"java\">\/\/ \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 public MemoryEfficientList(Class&lt;?> clazz, int size) {   this.clazz = clazz;   List&lt;Field> correctFields = getCorrectFields(clazz);      fieldTypes = new byte[correctFields.size()];     fieldOffsets = new long[correctFields.size()];    initFields(correctFields);        dataSize = size;   \/\/ \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043f\u0430\u043c\u044f\u0442\u044c     dataAddress = unsafe.allocateMemory(objectByteSize * size);      try {         \/\/ \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439         firstFast = buildNewObject();         secondFast = buildNewObject();         fastInternal = buildNewObject();         oldValue = buildNewObject();     } catch(Exception ignored) {     } }<\/code><\/pre>\n<p><code>unsafe.allocateMemory<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441 \u043d\u0438\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>unsafe.getInt(dataArray + byteOffset)<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 4 \u0431\u0430\u0439\u0442\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 dataArray + byteOffset.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0431\u0430\u0439\u0442\u044b \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0443:<\/p>\n<pre><code class=\"java\">private void decomposeObject(int pos, Object object) {         int offset = pos * objectByteSize;          for(int i = 0; i &lt; fieldTypes.length; i++) {             long fo = fieldOffsets[i];              switch(fieldTypes[i]) {                 case TYPE_BOOLEAN: {                     unsafe.putByte(dataAddress + offset,                                     (byte) (unsafe.getBoolean(object, fo) ? 1 : 0));                     offset += 1;                     break;                 }                  case TYPE_INT: {                     unsafe.putInt(dataAddress + offset, unsafe.getInt(object, fo));                     offset += 4;                     break;                 }             }         }     }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u0441\u0431\u043e\u0440\u043a\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0437 \u0431\u0430\u0439\u0442:<\/p>\n<pre><code class=\"java\">private void composeObject(int pos, Object object) {         long offset = pos * objectByteSize;          for(int i = 0; i &lt; fieldTypes.length; i++) {             long fo = fieldOffsets[i];             switch(fieldTypes[i]) {                 case TYPE_BOOLEAN: {                     unsafe.putBoolean(object, fo,                                        unsafe.getByte(dataAddress + offset) == 1);                     offset += 1;                     break;                 }                                  case TYPE_INT: {                     unsafe.putInt(object, fo, unsafe.getInt(dataAddress + offset));                     offset += 4;                     break;                 }             }         }     }<\/code><\/pre>\n<p>\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432:<\/p>\n<pre><code class=\"java\">public boolean add(Object o) {     \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u043e\u043d\u0435\u0446 \u043c\u0430\u0441\u0441\u0438\u0432\u0430     decomposeObject(size, o);     size += 1;     return true; }<\/code><\/pre>\n<p>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/p>\n<pre><code class=\"java\">public Object get(int index) {     \/\/ \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 getFast \u0438 getFast2 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f     \/\/ \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435     \/\/ \u043e\u0431\u044a\u0435\u043a\u0442\u044b: firstFast \u0438 secondFast     Object result = buildNewObject();     composeObject(index, result);     return result; }<\/code><\/pre>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443:<\/p>\n<pre><code class=\"java\">public Object remove(int index) {         composeObject(index, oldValue);          final int newSize = size - 1;          if(newSize > index)             unsafe.copyMemory((index + 1) * objectByteSize,                                index * objectByteSize,                                (newSize - index) * objectByteSize);            size = newSize;         return oldValue;     }<\/code><\/pre>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0442\u0435\u0441\u0442\u0430\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>CPU<\/p>\n<\/td>\n<td>\n<p>Intel Core i7 7600<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>RAM<\/p>\n<\/td>\n<td>\n<p>12GB, 2400 MHz<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>JVM<\/p>\n<\/td>\n<td>\n<p>OpenJDK 13.0.2, windows<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0411\u0435\u0437 \u0441\u043a\u043e\u0431\u043e\u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0442\u0435\u0441\u0442\u0430 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445, \u0432 \u0441\u043a\u043e\u0431\u043a\u0430\u0445 \u0441\u0440\u0435\u0434\u043d\u0435\u0435.<\/p>\n<p>MEL = MemoryEfficientList<\/p>\n<p>\u0422\u0435\u0441\u0442 0, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 N int \u0432 \u043c\u0430\u0441\u0441\u0438\u0432. \u041c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0434 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. <code>int[]<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>N<\/p>\n<\/td>\n<td>\n<p>ArrayList<\/p>\n<\/td>\n<td>\n<p>MEL<\/p>\n<\/td>\n<td>\n<p>int[]<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>10 000 000<\/p>\n<\/td>\n<td>\n<p>0.18 (0.27)<\/p>\n<\/td>\n<td>\n<p>0.15 (0.22)<\/p>\n<\/td>\n<td>\n<p>0.09 (0.10)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>1 000 000<\/p>\n<\/td>\n<td>\n<p>0.019 ( 0.037)<\/p>\n<\/td>\n<td>\n<p>0.015 (0.023)<\/p>\n<\/td>\n<td>\n<p>0.01 (0.01)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u0435\u043d \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f).<\/p>\n<p>\u0422\u0435\u0441\u0442 1, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 N \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 int, \u0437\u0430\u0442\u0435\u043c N \u0440\u0430\u0437 \u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 2 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430, \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0447\u0435\u043a \u0441\u0443\u043c\u043c\u0443.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f ArrayList<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">for(int i = 0; i &lt; n; i++)   al.add(r.nextInt());  for(int i = 0; i &lt; n; i++) {     int pos1 = r.nextInt(n);     int pos2 = r.nextInt(n);     Integer a = al.get(pos1);     Integer b = al.get(pos2);     al.set(pos1, b);     al.set(pos2, a); }<\/code><\/pre>\n<\/div>\n<\/details>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>N<\/p>\n<\/td>\n<td>\n<p>ArrayList&lt;Integer><\/p>\n<\/td>\n<td data-colwidth=\"167\" width=\"167\">\n<p>MEL<\/p>\n<\/td>\n<td>\n<p>MEL + getFast<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>10 000 000<\/p>\n<\/td>\n<td>\n<p>2.51 (2.99)<\/p>\n<\/td>\n<td data-colwidth=\"167\" width=\"167\">\n<p>1.61 (1.86)<\/p>\n<\/td>\n<td>\n<p>1.56 (1.73)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>1 000 000<\/p>\n<\/td>\n<td>\n<p>0.17 (0.19)<\/p>\n<\/td>\n<td data-colwidth=\"167\" width=\"167\">\n<p>0.07 (0.09)<\/p>\n<\/td>\n<td>\n<p>0.06 (0.08)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442: 24 \u0431\u0430\u0439\u0442\u0430. 4 \/ 28 = 14% \u043e\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 ArrayList&lt;Integer>.<\/p>\n<p>\u0422\u0435\u0441\u0442 2, \u0440\u0435\u0448\u0435\u0442\u043e \u042d\u0440\u0430\u0442\u043e\u0441\u0444\u0435\u043d\u0430, \u043f\u043e\u0438\u0441\u043a \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 1 \u0434\u043e N<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f ArrayList<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">for(int i = 0; i &lt; n; i++)     alIs.add(true);     alIs.set(0, false);     alIs.set(1, false);     for(int i = 0; i &lt; n; i++) {         if(alIs.get(i) &amp;&amp; i * i > 0) {             for(int j = i * i; j &lt; n; j += i)               alIs.set(j, false);             alResult.add(i);       } }<\/code><\/pre>\n<\/div>\n<\/details>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>N<\/p>\n<\/td>\n<td>\n<p>ArrayList<\/p>\n<\/td>\n<td>\n<p>MEL<\/p>\n<\/td>\n<td>\n<p>MEL + getFast<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>10 000 000<\/p>\n<\/td>\n<td>\n<p>1.00 (1.05)<\/p>\n<\/td>\n<td>\n<p>0.40 (0.41)<\/p>\n<\/td>\n<td>\n<p>0.37 (0.39)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>1 000 000<\/p>\n<\/td>\n<td>\n<p>0.035 (0.047)<\/p>\n<\/td>\n<td>\n<p>0.030 (0.040)<\/p>\n<\/td>\n<td>\n<p>0.023 (0.036)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438: 4 \u0431\u0430\u0439\u0442\u0430 (\u0441\u0441\u044b\u043b\u043a\u0430 \u0432 ArrayList) \u043f\u0440\u043e\u0442\u0438\u0432 1 \u0431\u0430\u0439\u0442\u0430 \u0432 MEL = 25% \u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0431\u0435\u0437 \u0443\u0447\u0451\u0442\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0432 \u043e\u0431\u044a\u0451\u043c\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<p>\u0422\u0435\u0441\u0442 3, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0442\u0435\u0441\u0442\u0443, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e Integer \u0431\u0443\u0434\u0435\u0442 Vec3{float x, y, z}.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>N<\/p>\n<\/td>\n<td>\n<p>ArrayList<\/p>\n<\/td>\n<td>\n<p>MEL<\/p>\n<\/td>\n<td>\n<p>MEL + getFast<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>10 000 000<\/p>\n<\/td>\n<td>\n<p>2.24 (2.40)<\/p>\n<\/td>\n<td>\n<p>1.87 (1.91)<\/p>\n<\/td>\n<td>\n<p>1.67 (1.71)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>1 000 000<\/p>\n<\/td>\n<td>\n<p>0.16 (0.18)<\/p>\n<\/td>\n<td>\n<p>0.15 (0.16)<\/p>\n<\/td>\n<td>\n<p>0.13 (0.14)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0439.<\/p>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438: 12 \u0431\u0430\u0439\u0442 \u043f\u0440\u043e\u0442\u0438\u0432 32 + 4 = 33% \u043e\u0442 \u043e\u0431\u044a\u0451\u043c\u0430 ArrayList.<\/p>\n<p>\u0422\u0435\u0441\u0442 4, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043f\u0435\u0440\u0432\u043e\u043c\u0443, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e Integer \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442:<\/p>\n<pre><code class=\"java\">public class LargeObject {     boolean x, y, z, w;     int i, j, k;     float a, b, c, d, e;     double g, h;     long m, n, o, p; }  \/\/ 84 \u0431\u0430\u0439\u0442\u0430<\/code><\/pre>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>N<\/p>\n<\/td>\n<td>\n<p>ArrayList<\/p>\n<\/td>\n<td>\n<p>MEL<\/p>\n<\/td>\n<td>\n<p>MEL + getFast<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>10 000 000<\/p>\n<\/td>\n<td>\n<p>2.53 (2.64)<\/p>\n<\/td>\n<td>\n<p>5.81 (5.94)<\/p>\n<\/td>\n<td>\n<p>5.09 (5.59)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>1 000 000<\/p>\n<\/td>\n<td>\n<p>0.15 (0.16)<\/p>\n<\/td>\n<td>\n<p>0.53 (0.56)<\/p>\n<\/td>\n<td>\n<p>0.47 (0.48)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0417\u0434\u0435\u0441\u044c MEL \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 ArrayList, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u0441\u0432\u0430\u043f\u0430\u0442\u044c 84 \u0431\u0430\u0439\u0442\u0430, \u0432\u043c\u0435\u0441\u0442\u043e 4.<\/p>\n<p>\u042d\u043a\u043e\u043d\u043e\u043c\u0438\u044f \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438: 84 + 16 + 4 (\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435) + 4 \/ 84 = 77% \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 ArrayList.<\/p>\n<p>\u0422\u0430\u043a \u043f\u0440\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0438 \u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d ~20 \u0431\u0430\u0439\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 MEL \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043d\u0438\u0437\u043a\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 toArray, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u0441\u0443\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 N \u043d\u043e\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u043a\u0443\u0447\u0435. \u042d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 Collections.sort, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f MEL \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438.<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e \u0437\u0430 \u0441\u0447\u0451\u0442 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0451\u043c\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0432\u0435\u0440\u043d\u044b\u043c. \u041f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 20-60% \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0437\u0430\u0434\u0430\u0447\u0438. \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0431\u043e\u043b\u044c\u0448\u0438\u0435 (\u0431\u043e\u043b\u044c\u0448\u0435 20 \u0431\u0430\u0439\u0442 \u0434\u0430\u043d\u043d\u044b\u0445) \u0442\u043e \u0440\u0430\u0437\u0443\u043c\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c ArrayList.<\/p>\n<p>\u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0435\u0439: \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041d\u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438.<\/p>\n<p>\u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0437\u0430 \u0441\u0447\u0451\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/p>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-327076","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/327076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=327076"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/327076\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=327076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=327076"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=327076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}