code: public final boolean compareAndSet(int i, int expect, int update) {
          if (fullWidth) {
              return array.compareAndSet(i, expect, update);
          }
  
          boolean success = false;
          int index = getIndex(i);
          int subIndex = getSubIndex(i);
          while (!success) {
              int prev = array.get(index);
              if (unPack(prev, subIndex) != expect) {
                  return false;
              }
  
              int next = pack(prev, update, subIndex);
              success = array.compareAndSet(index, prev, next);
          }
          return true;
      }
docs: Sets the element at the given index, but only if the previous value was the expected value.
  
  @param i the index
  @param expect the expected value
  @param update the new value
  @return true on success