find

Find if an item already exists in STL queue

无人久伴 提交于 2019-12-23 12:07:56
问题 I am using an STL queue to implement a BFS (breadth first search) on a graph. I need to push a node in the queue if that node already doesn't exist in the queue. However, STL queue does not allow iteration through its elements and hence I cannot use the STL find function. I could use a flag for each node to mark them when they are visited and push them only when the flag is false, however, I need to run BFS multiple times and after each time I will have to reset all the flags, so I ended up

How sort find result by file sizes

感情迁移 提交于 2019-12-23 09:36:50
问题 How can I sort by file size the results of the find command? I trying to sort the result of this find command: find ./src -type f -print0 I don't want the size of directories, I need the files relative paths sorted by size only. 回答1: Here is how to do using find command : find . -type f -exec ls -al {} \; | sort -k 5 -n | sed 's/ \+/\t/g' | cut -f 9 Here is how to do using recursive ls command : ls -lSR | sort -k 5 -n Or, if you want to display only file names: ls -lSR | sort -k 5 -n | sed 's

How to get the previous or next view

十年热恋 提交于 2019-12-23 09:36:24
问题 how can I get the previous view(TextView) of the SlideButton view, and the next view of the SlideButton view. The SlideButton view with the id "remotelight". I can get the SlideButton view with the method "findViewById". so after I get the SlideButton View, how can I get the previous view and the next view ,without the help of "findViewById" method. thanks so much. below is a part of layout xml: <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height=

batch find command not working

雨燕双飞 提交于 2019-12-23 09:26:25
问题 does anyone know why this would not work (Windows 7, batch script)? C:\testing>FINDSTR /R /N "^.*$" test.txt | FIND /C ":" FIND: `/C': No such file or directory FIND: `:': No such file or directory 回答1: try with : FINDSTR /R /N "^.*$" test.txt | %windir%\system32\FIND.exe /C ":" Meanwhile with: for %f in (find.exe) do @echo %~dpfnx$PATH:f (double % for batch file) you can see which FIND.EXE will be executed. 来源: https://stackoverflow.com/questions/19642548/batch-find-command-not-working

find command search only non hidden directories

≯℡__Kan透↙ 提交于 2019-12-23 08:59:53
问题 In the following command i want to search only only the directories which are non hidden how can i do this using the following command .Iwant to ignore hidden directories while searching the log file find /home/tom/project/ -name '.log.txt' ls /home/tom/project/ dir1 dir2 .backup .snapshot/ .ignore/ 回答1: Try find /home/tom/project -type d -name '.*' -prune -o -name .log.txt -print 回答2: This will find all files but ignore those that start with a dot so hidden files. find /home/tom/project/

Pass multiple strings to the string::find function

自闭症网瘾萝莉.ら 提交于 2019-12-23 08:56:39
问题 Is it possible to somehow pass multiple strings to the string::find function? For example, to find a string I might use this: str.find("a string"); What I'd like to do is something like this: str.find("a string" || "another string" || "yet another string") And have the function return the position of the first occurrence of any of the three strings. Thanks for any suggestions. 回答1: Not with std::string::find , but you could use std::find_if from <algorithm> : std::string str("a string"); std:

Matlab: How to find a point in a bounding box

守給你的承諾、 提交于 2019-12-23 06:30:22
问题 I have an array of points or locations that are scattered throughout a big matrix, and I have a small bounding box inside the matrix. I need a way to check if the points in the array are within the bounding box. Thanks for your suggestions. BoundingBox = [BB1,BB2,BB3,BB4]; Array = [x1,y1;x2,y2;x3,y3;x4,y4;x5,y5;x6,y6]; I have tried ismember([BB1,BB2,BB3,BB4],Array); and ismember(rectangle('Position',[BB1,BB2,BB3,BB4]),Array); but nothing is working 回答1: You should read ismember()'s

Entity Framework Filter By PrimaryKey

安稳与你 提交于 2019-12-23 05:29:12
问题 I'm writing a generic crud service I'm trying to implement the Get method with an optional virtual method to include properties However I'm having some trouble because FindAsync is only declared on a DbSet : public async virtual Task<TDTO> Get(object[] id) { // I want to do something like this var entity = await this.ApplyGetIncludes(this.GetEntityDBSet()).FindAsync(id) return this.AdaptToDTO(entity); } protected virtual DbSet<TEntity> GetEntityDBSet() { return this._context.Set<TEntity>(); }

obscure Unix find command syntax understanding

落爺英雄遲暮 提交于 2019-12-23 05:16:22
问题 Need help in understanding this complex Unix find command and its operation: find . \( \! -user xx -exec chown -- xx '{}' + -false \) -o \ \( \! -group root -exec chgrp -- root '{}' + \) -o \ \( ! -perm 700 -exec chmod -- 700 '{}' + -exec false \; \) Also, I am looking out in particular the purpose of -false predicate. I guess I mixed both GNU and non-GNU find syntax 回答1: The false predicate evaluated to false for -o and it is used here to prevent short short-circuiting. if user is not xx

Powershell script for going into texts files within a directory and replacing characters

不打扰是莪最后的温柔 提交于 2019-12-23 04:37:13
问题 Morning all, I'm trying to work out how to go into a number of text files within a directory, and replace the characters with the following: 'BS' = '\' 'FS' = '/' 'CO' = ':' What I managed to get to so far is: (get-content C:\users\x\desktop\info\*.txt) | foreach-object {$_ -replace "bs", "\"} | set-content C:\Users\x\desktop\info\*.txt I have got 6 text files, all with a line of text in them, the script above copies the line of text into all the text files. So what I end up with is 6 text