可以安全地修改std :: pair :: first的成对向量吗?(Safe To Modify std::pair::first in vector of pairs?)
我目前正在研究一个DNA数据库类,并且我现在将数据库中的每一行与匹配分数(基于编辑距离)和实际的DNA序列本身相关联,在迭代循环中以这种方式首先修改是否安全?
typedef std::pair<int, DnaDatabaseRow> DnaPairT; typedef std::vector<DnaPairT> DnaDatabaseT; // .... for(DnaDatabaseT::iterator it = database.begin(); it != database.end(); it++) { int score = it->second.query(query); it->first = score; }
我这样做的原因是为了让我可以在稍后分数。 我尝试过使用地图并收到有关首先修改的编译错误,但是有没有比此更好的方法来存储所有信息以便稍后进行排序?
I'm currently working on a DNA database class and I currently associate each row in the database with both a match score (based on edit distance) and the actual DNA sequence itself, is it safe to modify first this way within an iteration loop?
typedef std::pair<int, DnaDatabaseRow> DnaPairT; typedef std::vector<DnaPairT> DnaDatabaseT; // .... for(DnaDatabaseT::iterator it = database.begin(); it != database.end(); it++) { int score = it->second.query(query); it->first = score; }
The reason I am doing this is so that I can sort them by score later. I have tried maps and received a compilation error about modifying first, but is there perhaps a better way than this to store all the information for sorting later?
原文:https://stackoverflow.com/questions/330186
最满意答案
最简单的方法如下:
showChangeEmailView: function () { Ext.Viewport.add(this.getChangeEmailView()); this.getChangeEmailView().show({ type:'slide', direction:'up' }); }
但那真的取决于你的app结构。 也许您正在使用NavigationView,然后您需要推送视图。
希望这有帮助
The simplest way would be the following:
showChangeEmailView: function () { Ext.Viewport.add(this.getChangeEmailView()); this.getChangeEmailView().show({ type:'slide', direction:'up' }); }
But then it really depends of your app structure. Maybe you're working with a NavigationView and then you need to push the view.
Hope this helped
相关问答
更多-
Sencha Touch - 如何从控制器重新初始化地图视图(Sencha Touch - how to re-initialize a map view from a controller)[2024-02-18]
你得到的函数是未定义的消息,因为你的视图中没有定义reset()函数。 但是,如果要初始化MapView,则需要使用initialize()函数。 将其添加到您的文件中: Ext.define("App.view.MapView", { extend: 'Ext.Container', requires: [ 'Ext.device.Geolocation', 'Ext.MessageBox' ], xtype: 'mapview', constructor: function () { ... -
而不是ItemTpl只是写Tpl。 我怀疑itemTpl是否存在没有列表xtype。 其他的东西是把Tpl放在配置中: {tpl:['{descriptionddata}']} 我之前/之上的答案是好的,但是如果你打算将格式保留在视图中而不是在控制器中,那么它通过使用setData而不是setRecord来工作 detailview.setData({title:record.get('title'), description:reco ...
-
控制器可以是不同视图之间的粘合剂。 我不知道你有什么样的意见,但下面的代码可以作为基础: Ext.define('MyApp.controller.TestController', { extend : 'Ext.app.Controller', config : { views : [ // you need to list all views your controller will use 'Place', 'Peo ...
-
最简单的方法如下: showChangeEmailView: function () { Ext.Viewport.add(this.getChangeEmailView()); this.getChangeEmailView().show({ type:'slide', direction:'up' }); } 这是一个例子 但那真的取决于你的app结构。 也许您正在使用NavigationView,然后您需要推送视图。 希望这有帮助 The si ...
-
我检查了您的代码,发现由于导航视图导致此问题。 我不知道这个奇怪问题的原因,但将导航视图更改为Container解决了问题。 主要观点: - Ext.define('MyApp.view.MainView', { extend: 'Ext.Container', xtype: 'main', requires: [ 'Ext.form.Panel', 'Ext.Button' ], config: { itemId: 'mynavi ...
-
Sencha Touch 2 - 从控制器到视图的传递值是“未定义”(Sencha Touch 2 - Pass value from controller to view is “undefined”)[2021-12-30]
假设您的视图已在其config定义中进行了catid ,您应该使用setter / getter来访问该属性: sto.filter('categoryid', this.getCatid()); 添加到config项目会自动为它们创建设置/获取。 **编辑** 我正在添加您应该使用的完整视图代码。 this.getCatid()在initialize方法中不提供值的唯一原因是你没有传入一个值。 Ext.define('Catalog.view.showSearchCategory', { ext ... -
Sencha Touch 2.0控制器无法处理我的列表中的点击(Sencha Touch 2.0 Controller can't handle clicks to my list)[2021-11-19]
您发布的代码没有错。 它适用于此List: Ext.define('MyFirstApp.view.People', { extend: 'Ext.List', xtype: 'peoplelist', config: { fullscreen: true, itemTpl: '{first} {last}', store: 'Presidents' } }); 如果在配置中声明了xtype,则它不起作用。 Nothing wrong with the code you po ... -
Sencha Touch 2,使用get组件获取视图的名称(Sencha Touch 2, get the name of the view from using get component)[2021-07-31]
使用Ext.ClassManager.getClass(component); Use Ext.ClassManager.getClass(component); -
Sencha Touch MVC应用程序 - 控制器无法通过xtype查看(Sencha Touch MVC app - controller unable to get view by xtype)[2021-10-12]
如果没有找到,则需要告诉ref它必须创建一个实例。 glazeMaterialEditor: { selector: 'glazeMaterialEditor', xtype: 'glazeMaterialEditor', autoCreate: true } 有关更多信息,请参见参考资料 You will need to tell the ref that it has to create a instance if none is found. glazeMaterialEdi ... -
试试这段代码: Ext.require(controller, function() {//controller - "App.controller.Name" var c = Ext.create(controller, {application: this}), controllers; c.init(); c.launch(); /* The "getController" returns "undefined" for a dynamically loaded ...