java mutable_java.math.MutableBigInteger的目的是什么?

/**

* A class used to represent multiprecision integers that makes efficient

* use of allocated space by allowing a number to occupy only part of

* an array so that the arrays do not have to be reallocated as often.

* When performing an operation with many iterations the array used to

* hold a number is only reallocated when necessary and does not have to

* be the same size as the number it represents. A mutable number allows

* calculations to occur on the same number without having to create

* a new number for every step of the calculation as occurs with

* BigIntegers.

*

* @see BigInteger

* @version 1.12, 12/19/03

* @author Michael McCloskey

* @since 1.3

*/

我猜MutableBigInteger在内部用于BigInteger繁重的计算,这些计算会因频繁的重新分配而变慢.我不确定为什么它不作为java.math的一部分导出.也许对可变价值类有些厌恶?

澄清“可变”:

标准BigInteger在其整个生命周期中都有一个值,给定两个BigInteger引用“a”& “b”,“a b”将始终产生具有相同值的新BigInteger.假设价值是4.

使用MutableBigInteger,“ab”最初可以产生4,但由于其他代码改变了由“a”和amp引用的对象的值(也就是变异),在未来的某个时间点会产生8,16,32或任何其他数字. ; “B”.因此,Java中的大多数(可能是所有)值类型(Character,Short,Long,Integer,BigInteger,BigDecimal,Float,Double,甚至String)都是不可变的.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#include "prepare_ogm.hpp" namespace senior { namespace guardian { namespace prepare { std::string PrepareOgm::Name() { return "Prepare Ogm Element"; } void PrepareOgm::Initiate() {} void PrepareOgm::Process(data::DataFrame& his, data::DataFrame& cur) { if (cur.source_ogm_points_.is_invalid()) return; if (cur.source_visual_ogm_points_.is_valid()) { cur.source_ogm_points_.insert(cur.source_ogm_points_.end(), cur.source_visual_ogm_points_.begin(), cur.source_visual_ogm_points_.end()); } if (cur.source_higher_ogm_points_.is_valid()) { cur.source_ogm_points_.insert(cur.source_ogm_points_.end(), cur.source_higher_ogm_points_.begin(), cur.source_higher_ogm_points_.end()); } auto& predict_path = cur.monitor_data_.mutable_predict_path(); predict_path.GenerateBoundary(cur); cur.AABox2d_ = predict_path.vehicle_AABox2d_; // if (!his.monitor_data_.is_need_to_take_over()) { // LOG(INFO)<<"1"; cur.AABox2d_.SetWidth(cur.AABox2d_.width() + 1.0); cur.AABox2d_.SetLength(cur.AABox2d_.length() + 1.0); // } std::vector<math::Vec2d> corner_points_; cur.AABox2d_.GetAllCorners(&corner_points_); auto& polygon2d = predict_path.tractor_polygon2d_; math::Vec2d temp; VoxelGrid filter_; common::Time now = common::Time::Now(); for (auto& point : cur.source_ogm_points_) { temp.set_x(point.x()); temp.set_y(-point.y()); if (cur.AABox2d_.IsPointIn(temp)) { cur.AABB_ogm_points_.emplace_back(point); } } cur.guardian_diagnose_["Prepare_PrepareOgm_AABox_filter"] = std::to_string((common::Time::Now() - now).ToSecond() * 1000); now = common::Time::Now(); filter_.VoxelGrid_ApplyFilter( cur.AABB_ogm_points_, cur.ogm_points_, corner_points_, 0.1, 0.1, 0); cur.guardian_diagnose_["Prepare_PrepareOgm_VoxelGrid_ApplyFilter"] = std::to_string((common::Time::Now() - now).ToSecond() * 1000); cur.ogm_points_.set_stamp(cur.source_ogm_points_.stamp()); cur.ogm_points_.set_time(cur.source_ogm_points_.time()); cur.ogm_points_.set_delay_time(cur.source_ogm_points_.delay_time()); cur.ogm_points_.set_valid(); } } // namespace prepare } // namespace guardian } // namespace senior 改变为C语言程序
06-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值