• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ben-manes / caffeine / #5173

29 Dec 2025 05:27AM UTC coverage: 0.0% (-100.0%) from 100.0%
#5173

push

github

ben-manes
speed up development ci build

0 of 3838 branches covered (0.0%)

0 of 7869 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/caffeine/src/main/java/com/github/benmanes/caffeine/cache/WriteOrderDeque.java
1
/*
2
 * Copyright 2014 Ben Manes. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.github.benmanes.caffeine.cache;
17

18
import java.util.Deque;
19

20
import org.jspecify.annotations.Nullable;
21

22
import com.github.benmanes.caffeine.cache.WriteOrderDeque.WriteOrder;
23

24
/**
25
 * A linked deque implementation used to represent a write-order queue.
26
 *
27
 * @author ben.manes@gmail.com (Ben Manes)
28
 * @param <E> the type of elements held in this collection
29
 */
30
final class WriteOrderDeque<E extends WriteOrder<E>> extends AbstractLinkedDeque<E> {
×
31

32
  @Override
33
  public boolean contains(Object o) {
34
    return (o instanceof WriteOrder<?>) && contains((WriteOrder<?>) o);
×
35
  }
36

37
  // A fast-path containment check
38
  boolean contains(WriteOrder<?> e) {
39
    return (e.getPreviousInWriteOrder() != null)
×
40
        || (e.getNextInWriteOrder() != null)
×
41
        || (e == first);
42
  }
43

44
  @Override
45
  @SuppressWarnings("unchecked")
46
  public boolean remove(Object o) {
47
    return (o instanceof WriteOrder<?>) && remove((E) o);
×
48
  }
49

50
  // A fast-path removal
51
  public boolean remove(E e) {
52
    if (contains(e)) {
×
53
      unlink(e);
×
54
      return true;
×
55
    }
56
    return false;
×
57
  }
58

59
  @Override
60
  public @Nullable E getPrevious(E e) {
61
    return e.getPreviousInWriteOrder();
×
62
  }
63

64
  @Override
65
  public void setPrevious(E e, @Nullable E prev) {
66
    e.setPreviousInWriteOrder(prev);
×
67
  }
×
68

69
  @Override
70
  public @Nullable E getNext(E e) {
71
    return e.getNextInWriteOrder();
×
72
  }
73

74
  @Override
75
  public void setNext(E e, @Nullable E next) {
76
    e.setNextInWriteOrder(next);
×
77
  }
×
78

79
  /**
80
   * An element that is linked on the {@link Deque}.
81
   */
82
  interface WriteOrder<T extends WriteOrder<T>> {
83

84
    /**
85
     * Retrieves the previous element or {@code null} if either the element is unlinked or the
86
     * first element on the deque.
87
     */
88
    @Nullable T getPreviousInWriteOrder();
89

90
    /** Sets the previous element or {@code null} if there is no link. */
91
    void setPreviousInWriteOrder(@Nullable T prev);
92

93
    /**
94
     * Retrieves the next element or {@code null} if either the element is unlinked or the last
95
     * element on the deque.
96
     */
97
    @Nullable T getNextInWriteOrder();
98

99
    /** Sets the next element or {@code null} if there is no link. */
100
    void setNextInWriteOrder(@Nullable T next);
101
  }
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc