/** * A persistent data structure does preserve the previous version of itself when being modified and is therefore effectively immutable. Fully persistent data structures allow both updates and queries on any version. * */ private void createCollection() { System.out.println(); System.out.println("createList"); List<Integer> list1 = List.of(1, 2, 3); System.out.println(list1); // print List(1, 2, 3) List<Integer> list2 = list1.tail().prepend(0); System.out.println(list2); // print List(0, 2, 3) System.out.println(); System.out.println("createQueue"); Queue<Integer> queue = Queue.of(1, 2, 3) .enqueue(4) .enqueue(5); System.out.println(queue); // print Queue(1, 2, 3, 4, 5) }
if (!this.attribute_queue.isEmpty()) { final SMFAttribute next = this.attribute_queue.head(); if (Objects.equals(name, next.name())) { this.attribute_queue = this.attribute_queue.tail(); this.attribute_values_remaining = this.header.vertexCount(); this.attribute_current = next; sb.append(System.lineSeparator()); sb.append(" Expected: "); if (!this.attribute_queue.isEmpty()) { sb.append(this.attribute_queue.head().name().value()); } else { sb.append("(no attribute expected)");
@Encoding.Naming(value = "setIterable*") @Encoding.Init void setIterable( final Iterable<T> elements) { this.queue = Queue.ofAll(elements); }
@Encoding.Naming(value = "enqueue*", depluralize = true) @Encoding.Init void enqueue( final T element) { this.queue = this.queue.enqueue(element); }
@Override public void serializeDataStart() throws IllegalStateException, IOException { this.state.transition(SerializerState.STATE_DATA_ATTRIBUTES_START); this.writer.append("data"); this.writer.newLine(); if (this.attribute_queue.isEmpty()) { this.state.transition(SerializerState.STATE_DATA_ATTRIBUTES_IN_PROGRESS); this.state.transition(SerializerState.STATE_DATA_ATTRIBUTES_FINISHED); } }
@Encoding.Naming(value = "enqueueAll*", depluralize = true) @Encoding.Init void enqueueAll( final Iterable<T> element) { this.queue = this.queue.enqueueAll(element); }
this.attribute_queue = Queue.ofAll(attributes); final SMFTriangles triangles = in_header.triangles(); this.triangle_values_remaining = triangles.triangleCount();
private void serializeValueUpdateRemaining() throws IOException { Preconditions.checkPrecondition( this.state.current(), this.state.current() == SerializerState.STATE_DATA_ATTRIBUTES_IN_PROGRESS, s -> s + " must be " + SerializerState.STATE_DATA_ATTRIBUTES_IN_PROGRESS); this.attribute_values_remaining = Math.subtractExact(this.attribute_values_remaining, 1L); if (this.attribute_values_remaining == 0L) { if (this.attribute_queue.isEmpty()) { this.state.transition(SerializerState.STATE_DATA_ATTRIBUTES_FINISHED); } } }