jmalkin commented on code in PR #438: URL: https://github.com/apache/datasketches-cpp/pull/438#discussion_r1718024954
########## filters/include/bit_array_ops.hpp: ########## @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef _BIT_ARRAY_OPS_HPP_ +#define _BIT_ARRAY_OPS_HPP_ + +#include <bitset> + +namespace datasketches { + +/** + * This class comprises methods that operate one or more arrays of bits (uint8_t*) to + * provide bit array operations. The class does not take ownership of memory and operates On + * arrays in-place. Sizes of the arrays, in bytes, are passed in as arguments. + * + * None of the methods in this class perform bounds checks. The caller is responsible for ensuring + * that indices are within the array bounds. + * + * Implementation assumes the actual arrays are multiples of 64 bits in length. + */ +namespace bit_array_ops { + + /** + * Get the value of a bit at the given index. + * @param array the array of bits + * @param index the index of the bit to get + * @return the value of the bit at the given index. + */ + static inline bool get_bit(uint8_t* array, const uint64_t index) { Review Comment: The main advantage is that the compiler ensures you're not going to inadvertently try writing to a value that should never change. But that's fine. I'll remove them in many places. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
