record

What are the pros and cons of using dynamic array of records vs. TList<TMyRecord> in Delphi?

给你一囗甜甜゛ 提交于 2019-12-07 01:13:57
问题 This is a theoretical question intended to generate a look-up list of pros and cons of different data storage ways in Delphi. Let's say we have a record: type TMyRecord = record X,Y,Z: Single; IsValid: Boolean; end; Basic options of storing an array of such records are: array of TMyRecord; custom descendant of TList with getter/setter TList<TMyRecord>; I'm specifically interested about #1 vs #3 comparison, how much is the difference between those, especially performance-wise. 回答1: TList<T>

Record equality in generic collections

丶灬走出姿态 提交于 2019-12-06 23:29:07
问题 Assume you have a record with an overloaded equality operator TSomeRecord = record Value : String; class operator Equal(Left, Right : TSomeRecord) : Boolean; end; (implementation compares string values). If adding two records to the list that are equal based on the overloaded operator I would expect the Contains method to return true in both cases. But in fact, the generic list seems to just compare the memory content of records instead of applying the overloaded equality operator. var List :

F# Optional Record Field

ⅰ亾dé卋堺 提交于 2019-12-06 18:31:12
问题 I have a F# record type and want one of the fields to be optional: type legComponents = { shares : int<share> ; price : float<dollar / share> ; totalInvestment : float<dollar> ; } type tradeLeg = { id : int ; tradeId : int ; legActivity : LegActivityType ; actedOn : DateTime ; estimates : legComponents ; ?actuals : legComponents ; } in the tradeLeg type I would like the the actuals field to be optional. I can't seem to figure it out nor can I seem to find a reliable example on the web. It

Record-type recursive member functions and the “rec” keyword

允我心安 提交于 2019-12-06 16:43:17
问题 I've always believed that in F# we needed to use the rec keyword for every recursive function, for example: let rec factorial = function | 0 -> 1 | k when k > 0 -> k * (factorial (k - 1)) | failwith "oops!" Today I was playing around with F# and I came up with a code similar to the following: let MyRecordType = { Something : float; SomethingElse : int } with static member factorial = function | 0 -> 1 | k when k > 0 -> k * (MyRecordType.factorial (k - 1)) | failwith "oops!" As you see, I've

Record the Firefox tab as a video like screencastify on chrome

旧街凉风 提交于 2019-12-06 15:56:35
问题 I would like to record a firefox browser tab through browser extension like Screencastify extension does in chrome. About Recording Session of chrome extension , chrome.tabCapture API is used to get the stream of the currently active tab and to record the stream RecordRTC.js of Web-RTC Experiment is used. Like wise, Is there any API in Mozilla Firefox to get the stream of the tab in Firefox browser. P.S : I am asking about recording the tab of the firefox not recording the screen or window or

How to use high order functions to filter and match on options fields in a record

空扰寡人 提交于 2019-12-06 14:31:03
问题 So a bit of context is required just to understand my issue. In an RPG, I consider the equipment as a record with optional fields, which means, while they're None that nothing was attributed yet. Equipment is constructed by the game items of the game that represents either weaponry or character protection (helmets and etc) which will be seen in the snippet below. The functionalities are removed and the domain model reduced to make it easier to read. type ConsummableItem = | HealthPotion |

MediaPlayer Preparing Failed

若如初见. 提交于 2019-12-06 11:43:45
问题 All I have been doing for the past 8 hours is trying to come up with a simple recorder/ playback app. I want to be able to record the audio in 3GP and then have it automatically loaded into the MediaPlayer so that I can play it back. I am 80% sure that it is recording and saving to the location specified in the code, but when I try and load it into my media player I always get this error. I have tried loading the toto_africa.mp3 file too to make sure it's not the recorded file's problem, and

Capture mac screen

寵の児 提交于 2019-12-06 09:30:38
What is the best way to record the mac screen with cocoa? I know there are many examples at the apple developer reference library. SonOfGrab explain how to capture the screen with quartz but also that it isn't enough fast to use it to grab many frames every second. OpenGLScreenSnapshot has same results but it isn't fast, too. OpenGLScreenCapture seems to be the best way to do it but XCode prompts me many errors because it's made for 10.4 and it requires old Quicktime commands I think they pushed into QTKit but I can't find a way to convert it. Could anyone send me to someone's site that

How to generically extract field names and values in Haskell records

↘锁芯ラ 提交于 2019-12-06 09:22:18
问题 I recently learned that I can do the following in Haskell: {-# LANGUAGE DeriveDataTypeable #-} import Data.Data data MyRecord = MyRecord { field1 :: Int , field2 :: String , field3 :: String } deriving (Show,Eq,Data,Typeable) main = print $ constrFields (toConstr (MyRecord 5 "Hello" "World")) This will give me the following: ["field1","field2","field3"] How can I do the same thing for the values in a record, like this: ["5","Hello","World"] I'm asking because I'm using Aeson to take simple

Haskell Esqueleto project subset of columns to list of custom records

和自甴很熟 提交于 2019-12-06 08:59:32
问题 In all the examples I have seen the results from esqueleto are projected into a list of tuples or to entities records. For example: previousLogItems <- select $ from $ \li -> do orderBy [desc (li ^. LogItemId)] limit 10 return (li ^. LogItemId, li ^. LogItemTitle) Is there any way in esqueleto to project a subset of the columns to custom records (different than the entity) instead of tuples? This being done without an extra projection from tuples to custom records. As an example, let's say