code: public ImmutableIndex<V> buildImmutableIndex() {
          // The current AlphabeticIndex Java code never modifies the bucket list once built.
          // If it contains no records, we can use it.
          // addRecord() sets buckets=null rather than inserting the new record into it.
          BucketList<V> immutableBucketList;
          if (inputList != null && !inputList.isEmpty()) {
              // We need a bucket list with no records.
              immutableBucketList = createBucketList();
          } else {
              if (buckets == null) {
                  buckets = createBucketList();
              }
              immutableBucketList = buckets;
          }
          return new ImmutableIndex<V>(immutableBucketList, collatorPrimaryOnly);
      }
docs: Builds an immutable, thread-safe version of this instance, without data records.
  
  @return an immutable index instance