size

获取图片尺寸信息

£可爱£侵袭症+ 提交于 2020-03-20 22:19:18
这个是从网上找到的,具体是谁写的已经记不清了,非原创! /** * 获取远程图片的宽高和字节数 * @param string $url * @param string $isGetFilesize * @return boolean|multitype:string number */ private function getImageInfo($url, $isGetFilesize = false) { $result = array(); if (empty($url)) { return false; } $handle = fopen($url, 'rb'); if (! $handle) return false; // 只取头部固定长度168字节数据 $dataBlock = fread($handle, 168); $size = getimagesize('data://image/jpeg;base64,'. base64_encode($dataBlock)); if (empty($size)) { return false; } $result['width'] = isset($size[0]) ? intval($size[0]) : 0; $result['height'] = isset($size[1]) ? intval($size[1])

逻辑回归 C++

我的梦境 提交于 2020-03-14 15:36:04
#include <iostream> #include <string> #include <fstream> #include <sstream> #include <vector> #include <cmath> template <typename DataType> double sigmoid(DataType z) { return 1.0/(1+exp((-1)*z)); } template <typename DataType, typename WeightType> double getMatResult(typename::std::vector<DataType> &data, typename::std::vector<WeightType> &weights) { double result=0.0; for(size_t i=0;i<data.size();++i) { result+=data.at(i)*weights.at(i); } return result; } template <typename DataType> void DisplayData(typename::std::vector<std::vector<DataType> > &vv) { std::cout<<"the number of data: "<<vv

对ListCtrl - button的修改

廉价感情. 提交于 2020-03-08 12:28:03
从别处下了个“ListCtrl-Button”Demo发现总体不错,但有一些小问题,如: 1、Button列不在可视区域时 2、改变列宽时(拖动或双击) 3、滚动时 4、删除时 改后代码如下: ListCtrlEx.h 代码 /* ******************************************************************* * Project : NetMonitor * FileName : ListCtrlEx.h * Change : * Brief : * Author : Chen Jun ( chenjun@3cis.com.cn ) * Copyright ( c ) 2007-2008 3cis * All Right Reserved ******************************************************************** */ #if !defined( AFX_LISTCTRLEX_H__3D2C6B4A_4031_48EF_8162_492882D99D43__INCLUDED_ ) #define AFX_LISTCTRLEX_H__3D2C6B4A_4031_48EF_8162_492882D99D43__INCLUDED_ #if _MSC_VER > 1000

C++ vector.size() warning C4018

梦想的初衷 提交于 2020-03-08 07:07:30
node_vec为vector 若写为 for ( int j = 1 ; j < node_vec . size ( ) ; j ++ ) { node_vec [ j - 1 ] - > next = node_vec [ j ] ; } 也会运行得到正确的结果,但会有warning: warning C4018: “<”: 有符号/ 这是由于C++中vector的size()为unsigned int类型。 应该写为: for ( unsigned int j = 1 ; j < node_vec . size ( ) ; j ++ ) { node_vec [ j - 1 ] - > next = node_vec [ j ] ; } 来源: CSDN 作者: Gianna K 链接: https://blog.csdn.net/weixin_44208324/article/details/104555673

如何按比例缩放UIImageView?

青春壹個敷衍的年華 提交于 2020-03-07 12:02:10
我有一个UIImageView,目标是通过给它一个高度或宽度按比例缩小它。 UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://farm4.static.flickr.com/3092/2915896504_a88b69c9de.jpg"]]]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; //Add image view [self.view addSubview:imageView]; //set contentMode to scale aspect to fit imageView.contentMode = UIViewContentModeScaleAspectFit; //change width of frame CGRect frame = imageView.frame; frame.size.width = 100; imageView.frame = frame; 图像确实调整了大小但位置不在左上角。 缩放image / imageView的最佳方法是什么?如何更正位置? #1楼 imageView

数据结构--堆

泄露秘密 提交于 2020-03-05 02:48:25
堆,与其说是一种数据结构,不如说是一种排序算法。用堆算法,可以轻松得到一组数据中最大的或最小的元素。 其结构就是完全二叉树的顺序存储方式。即在一个数组中存储一颗完全二叉树。 通常,堆分为"大根堆"和"小根堆",前者的树顶元素是数组中最大的一个,后者是最小的一个。 常用操作: 入堆:元素被加入到堆中,以小根堆为例,新元素首先被放到队列最尾端,然后何其父节点比较,如果小于其父节点,则交换两者。以此类推,一直追溯到树顶元素,或者在半途,它不再小于它的父节点。操作完成。 出堆:出堆操作,就是得到当前队列中最大或最小的元素。对于一个合法的堆结构,其首元素就是所要找的。关键是这个元素取出后,其他元素要填补其移走的空白。和入堆操作相反,出堆操作是从树顶至叶节点的操作。 将一个队列构建成堆:这个操作相对复杂一些,每次都从堆底向堆顶找到其最大或最小的元素,然后分别对起两个子节点作此操作。 1 #include " Array.h " 2 #include < utility > 3 #include < algorithm > 4 template < typename T > 5 class heap 6 { 7 public : 8 heap(){} 9 10 void push_heap( const T & data) 11 // 入堆 12 { 13 if (m_array.empty()

lucene quickstart-基本检索

五迷三道 提交于 2020-03-01 21:20:25
有了上一篇建立的索引,就可以进行检索了。 数据库查询使用SQL,lucene检索使用Query。 lucene提供了一个IndexSearcher类,检索的功能通过这个类完成,其构造方法需要一个IndexReader对象。IndexReader用于读取索引库Directory。 IndexSearcher有许多重构的方法,其中返回值为TopDocs类型的为最简单的。本文使用这个方法进行演示。TopDocs保存检索结果,其中的scoreDocs属性保存了记录的docId及评分,根据docId就可以取得对应的记录。 上一篇中已经知道初始化Directory对象需要索引库的路径,我们提供一个Searcher类,简化索引的操作。 伪代码如下: public class Searcher { /** * 检索 * * @param indexDir * 索引存放目录 * @param query * 检索条件 * @param n * 返回结果数量 * @return * @throws Exception */ public List<Document> search(String indexDir, Query query, int n) throws Exception { 创建Directory对象; 创建IndexReader对象; 创建IndexSearcher对象;

LEETCODE#66加一

陌路散爱 提交于 2020-02-29 22:09:03
给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一。最高位数字存放在数组的首位, 数组中每个元素只存储单个数字。你可以假设除了整数 0 之外,这个整数不会以零开头。 1. 从后向前找,末位非0直接加1;末位为9则改为0,若前一位非9则加1返回,若前一位为9则加至非9返回;若为99形式,首位置1末位加0。 vector<int> plusOne(vector<int>& digits) { int num = digits.size(); if(digits[num-1] != 9) { digits[num-1]++; return digits; } for(int i = num-1; i >= 0; i--) { if(digits[i] == 9) digits[i] = 0; else{ digits[i] ++; return digits; } } digits.insert(digits.begin(), 1); return digits; } 2. 从后向前,找到第一个不为9的数,该位+1,该位后的数均变为0;未找到的话,说明该数全为9,则返回 1 加 digits.size()个0 vector<int> plusOne(vector<int>& digits) { int len=digits.size(); for(int i=len-1;i

mongodb 中查询子分类的数量

让人想犯罪 __ 提交于 2020-02-29 18:09:35
数据结构大概是这样的: { "_id" : ObjectId("5cbd9384ec422c7a39cfb4d4"), "city" : [ { "count" : NumberLong(1), "rank" : NumberLong(1), "score" : NumberLong(0), "tagid" : "北京", "tagone" : "0", "tagthree" : "0", "tagtwo" : "0", "tagtype" : NumberLong(5), "username" : "v2716770" } ], "industry" : [], "power" : [ { "count" : NumberLong(100), "rank" : NumberLong(1), "score" : NumberLong(10000000), "tagid" : "5", "tagone" : "0", "tagthree" : "0", "tagtwo" : "0", "tagtype" : NumberLong(4), "username" : "v2716770" }, { "count" : NumberLong(1), "rank" : NumberLong(2), "score" : NumberLong(8), "tagid" : "2", "tagone